public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH 0/8] Further testsuite fixes
@ 2023-01-10 16:37 Jon Turney
  2023-01-10 16:37 ` [PATCH 1/8] Cygwin: testsuite: automake doesn't define objdir Jon Turney
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

This gets us from:

> FAIL: cygload (execute)
> FAIL: devdsp.c (execute)
> FAIL: ltp/access05.c (execute)
> FAIL: ltp/fcntl07.c (execute)
> FAIL: ltp/fcntl07B.c (execute)
> FAIL: ltp/fork09.c (execute)
> FAIL: ltp/link04.c (execute)
> FAIL: ltp/symlink03.c (execute)
> FAIL: msgtest.c (execute)
> FAIL: pthread/cancel11.c (execute)
> FAIL: pthread/cancel3.c (execute)
> FAIL: pthread/cancel5.c (execute)
> FAIL: pthread/inherit1.c (execute)
> FAIL: pthread/mutex5.c (execute)
> FAIL: pthread/mutex7.c (execute)
> FAIL: pthread/mutex7d.c (execute)
> FAIL: pthread/mutex7n.c (execute)
> FAIL: pthread/priority1.c (execute)
> FAIL: pthread/priority2.c (execute)
> FAIL: pthread/rwlock6.c (execute)
> FAIL: semtest.c (execute)
> FAIL: shmtest.c (execute)
> FAIL: systemcall.c (execute)
> 
> 		=== winsup Summary ===
> 
> # of expected passes		255
> # of unexpected failures	23
> # of expected failures		6

to:

> FAIL: cygload
> FAIL: devdsp.c
> FAIL: ltp/access05.c
> FAIL: ltp/fcntl07.c
> FAIL: ltp/fork09.c
> FAIL: ltp/symlink01.c
> FAIL: ltp/symlink03.c
> FAIL: ltp/umask03.c
> FAIL: pthread/cancel11.c
> FAIL: pthread/cancel3.c
> FAIL: pthread/cancel5.c
> FAIL: pthread/inherit1.c
> FAIL: pthread/priority1.c
> FAIL: pthread/priority2.c
> FAIL: systemcall.c
> 
> 		=== winsup Summary ===
> 
> # of expected passes		263
> # of unexpected failures	15
> # of expected failures		5

which is almost manageable!

Jon Turney (8):
  Cygwin: testsuite: automake doesn't define objdir
  Cygwin: testsuite: Build testcases using automake
  Cygwin: testsuite: Fix compilation warnings
  Cygwin: testsuite: 64-bit fixes in pthread testcases
  Cygwin: testsuite: Update mutex tests for changed default mutex type
  Cygwin: testsuite: Update pthread tests for default SCHED_FIFO
  Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper
  Cygwin: CI: Run cygserver for tests

 .github/workflows/cygwin.yml                  |  16 +-
 winsup/configure.ac                           |   2 +-
 winsup/testsuite/Makefile.am                  | 309 +++++++++++++++++-
 winsup/testsuite/README                       |   2 +-
 winsup/testsuite/cygrun.c                     |  16 -
 winsup/testsuite/libltp/include/usctest.h     |   2 +-
 .../testsuite/{cygrun => mingw}/Makefile.am   |  11 +-
 winsup/testsuite/winsup.api/cygload.exp       |  32 +-
 winsup/testsuite/winsup.api/ltp/execv01.c     |   2 +-
 winsup/testsuite/winsup.api/ltp/execve01.c    |   2 +-
 winsup/testsuite/winsup.api/ltp/execvp01.c    |   2 +-
 winsup/testsuite/winsup.api/ltp/mmap02.c      |  10 +-
 winsup/testsuite/winsup.api/ltp/mmap03.c      |  10 +-
 winsup/testsuite/winsup.api/ltp/mmap04.c      |  10 +-
 winsup/testsuite/winsup.api/ltp/mmap05.c      |  10 +-
 winsup/testsuite/winsup.api/ltp/mmap06.c      |   8 +-
 winsup/testsuite/winsup.api/ltp/mmap07.c      |   8 +-
 winsup/testsuite/winsup.api/ltp/mmap08.c      |   8 +-
 winsup/testsuite/winsup.api/mmaptest03.c      |   2 +-
 winsup/testsuite/winsup.api/pthread/cancel2.c |  10 +-
 winsup/testsuite/winsup.api/pthread/cancel3.c |  10 +-
 winsup/testsuite/winsup.api/pthread/cancel4.c |  10 +-
 winsup/testsuite/winsup.api/pthread/cancel5.c |  12 +-
 .../testsuite/winsup.api/pthread/cleanup2.c   |  10 +-
 .../testsuite/winsup.api/pthread/cleanup3.c   |   8 +-
 .../testsuite/winsup.api/pthread/condvar2_1.c |  12 +-
 .../testsuite/winsup.api/pthread/condvar3_1.c |  12 +-
 .../testsuite/winsup.api/pthread/condvar3_2.c |  14 +-
 winsup/testsuite/winsup.api/pthread/exit3.c   |   2 +-
 .../testsuite/winsup.api/pthread/inherit1.c   |  12 +-
 winsup/testsuite/winsup.api/pthread/join1.c   |  10 +-
 winsup/testsuite/winsup.api/pthread/join2.c   |   8 +-
 winsup/testsuite/winsup.api/pthread/mutex4.c  |   2 +-
 winsup/testsuite/winsup.api/pthread/mutex5.c  |   2 +-
 winsup/testsuite/winsup.api/pthread/mutex7.c  |   3 +-
 winsup/testsuite/winsup.api/pthread/mutex7d.c |   3 +-
 winsup/testsuite/winsup.api/pthread/mutex7n.c |   1 -
 .../testsuite/winsup.api/pthread/priority1.c  |  10 +-
 .../testsuite/winsup.api/pthread/priority2.c  |  12 +-
 winsup/testsuite/winsup.api/pthread/rwlock6.c |  22 +-
 .../winsup.api/samples/sample-miscompile.c    |   1 -
 winsup/testsuite/winsup.api/systemcall.c      |   2 +-
 winsup/testsuite/winsup.api/user_malloc.c     |   4 +-
 winsup/testsuite/winsup.api/winsup.exp        |  37 +--
 44 files changed, 470 insertions(+), 221 deletions(-)
 rename winsup/testsuite/{cygrun => mingw}/Makefile.am (58%)
 delete mode 100644 winsup/testsuite/winsup.api/samples/sample-miscompile.c

-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/8] Cygwin: testsuite: automake doesn't define objdir
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 2/8] Cygwin: testsuite: Build testcases using automake Jon Turney
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

objdir isn't a predefined output variable in Automake (any more?), so
this was just using the absolute path /testsuite as the test's temporary
directory.  Use builddir instead.
---
 winsup/testsuite/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index a7b435c46..a2fa34811 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -38,7 +38,7 @@ RUNTESTFLAGS_1 = -v
 RUNTESTFLAGS = $(RUNTESTFLAGS_$(V))
 
 # a temporary directory, to be used for files created by tests
-tmpdir = $(abspath $(objdir)/testsuite/tmp/)
+tmpdir = $(abspath $(builddir)/tmp/)
 # the same temporary directory, as an absolute, /cygdrive path (so it can be
 # understood by the test DLL, which will have a different mount table)
 testdll_tmpdir = $(shell cygpath -ma $(tmpdir) | sed -e 's#^\([A-Z]\):#/cygdrive/\L\1#')
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/8] Cygwin: testsuite: Build testcases using automake
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
  2023-01-10 16:37 ` [PATCH 1/8] Cygwin: testsuite: automake doesn't define objdir Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 3/8] Cygwin: testsuite: Fix compilation warnings Jon Turney
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Build all the testcase executables directly using automake, rather than
passing the compiler information into DejaGnu to have it build them.

(This means you get build avoidance for these executables, so they only
get built once, rather than every time you run the test, and makes it
much easier to run them in isolatation against the installed Cygwin,
which is really nice to have when trying to fix broken tests...)

Rename the 'cygrun' subdirectory to 'mingw', and build all the testsuite
MinGW executables there.

Drop sample-miscompile.c (testing that compile failure is detected is
perhaps useful, but not here...)
---
 winsup/configure.ac                           |   2 +-
 winsup/testsuite/Makefile.am                  | 307 +++++++++++++++++-
 winsup/testsuite/README                       |   2 +-
 .../testsuite/{cygrun => mingw}/Makefile.am   |  11 +-
 winsup/testsuite/winsup.api/cygload.exp       |  32 +-
 .../winsup.api/samples/sample-miscompile.c    |   1 -
 winsup/testsuite/winsup.api/winsup.exp        |  37 +--
 7 files changed, 325 insertions(+), 67 deletions(-)
 rename winsup/testsuite/{cygrun => mingw}/Makefile.am (58%)
 delete mode 100644 winsup/testsuite/winsup.api/samples/sample-miscompile.c

diff --git a/winsup/configure.ac b/winsup/configure.ac
index 7a2121dae..b155cabe4 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -126,7 +126,7 @@ AC_CONFIG_FILES([
     utils/Makefile
     utils/mingw/Makefile
     testsuite/Makefile
-    testsuite/cygrun/Makefile
+    testsuite/mingw/Makefile
 ])
 
 AC_OUTPUT
diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index a2fa34811..7853d98e8 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -31,6 +31,300 @@ libltp_a_SOURCES = \
 	libltp/lib/tst_tmpdir.c \
 	libltp/lib/write_log.c
 
+check_PROGRAMS = \
+	winsup.api/checksignal \
+	winsup.api/crlf \
+	winsup.api/devdsp \
+	winsup.api/devzero \
+	winsup.api/iospeed \
+	winsup.api/mmaptest01 \
+	winsup.api/mmaptest02 \
+	winsup.api/mmaptest03 \
+	winsup.api/mmaptest04 \
+	winsup.api/msgtest \
+	winsup.api/nullgetcwd \
+	winsup.api/resethand \
+	winsup.api/semtest \
+	winsup.api/shmtest \
+	winsup.api/sigchld \
+	winsup.api/signal-into-win32-api \
+	winsup.api/systemcall \
+	winsup.api/user_malloc \
+	winsup.api/waitpid \
+	winsup.api/ltp/access01 \
+	winsup.api/ltp/access03 \
+	winsup.api/ltp/access04 \
+	winsup.api/ltp/access05 \
+	winsup.api/ltp/alarm01 \
+	winsup.api/ltp/alarm02 \
+	winsup.api/ltp/alarm03 \
+	winsup.api/ltp/alarm07 \
+	winsup.api/ltp/asyncio02 \
+	winsup.api/ltp/chdir02 \
+	winsup.api/ltp/chdir04 \
+	winsup.api/ltp/chmod01 \
+	winsup.api/ltp/chmod02 \
+	winsup.api/ltp/chown01 \
+	winsup.api/ltp/close01 \
+	winsup.api/ltp/close02 \
+	winsup.api/ltp/close08 \
+	winsup.api/ltp/creat01 \
+	winsup.api/ltp/creat03 \
+	winsup.api/ltp/creat09 \
+	winsup.api/ltp/dup01 \
+	winsup.api/ltp/dup02 \
+	winsup.api/ltp/dup03 \
+	winsup.api/ltp/dup04 \
+	winsup.api/ltp/dup05 \
+	winsup.api/ltp/execl01 \
+	winsup.api/ltp/execle01 \
+	winsup.api/ltp/execlp01 \
+	winsup.api/ltp/execv01 \
+	winsup.api/ltp/execve01 \
+	winsup.api/ltp/execvp01 \
+	winsup.api/ltp/exit01 \
+	winsup.api/ltp/exit02 \
+	winsup.api/ltp/fchdir01 \
+	winsup.api/ltp/fchdir02 \
+	winsup.api/ltp/fchmod01 \
+	winsup.api/ltp/fchown01 \
+	winsup.api/ltp/fcntl02 \
+	winsup.api/ltp/fcntl03 \
+	winsup.api/ltp/fcntl04 \
+	winsup.api/ltp/fcntl05 \
+	winsup.api/ltp/fcntl07 \
+	winsup.api/ltp/fcntl07B \
+	winsup.api/ltp/fcntl08 \
+	winsup.api/ltp/fcntl09 \
+	winsup.api/ltp/fcntl10 \
+	winsup.api/ltp/fork01 \
+	winsup.api/ltp/fork02 \
+	winsup.api/ltp/fork03 \
+	winsup.api/ltp/fork04 \
+	winsup.api/ltp/fork06 \
+	winsup.api/ltp/fork07 \
+	winsup.api/ltp/fork09 \
+	winsup.api/ltp/fork10 \
+	winsup.api/ltp/fork11 \
+	winsup.api/ltp/fpathconf01 \
+	winsup.api/ltp/fstat01 \
+	winsup.api/ltp/fstat02 \
+	winsup.api/ltp/fstat03 \
+	winsup.api/ltp/fstat04 \
+	winsup.api/ltp/fsync01 \
+	winsup.api/ltp/ftruncate01 \
+	winsup.api/ltp/ftruncate02 \
+	winsup.api/ltp/ftruncate03 \
+	winsup.api/ltp/getegid01 \
+	winsup.api/ltp/geteuid01 \
+	winsup.api/ltp/getgid01 \
+	winsup.api/ltp/getgid02 \
+	winsup.api/ltp/getgid03 \
+	winsup.api/ltp/getgroups01 \
+	winsup.api/ltp/getgroups02 \
+	winsup.api/ltp/gethostid01 \
+	winsup.api/ltp/gethostname01 \
+	winsup.api/ltp/getpgid01 \
+	winsup.api/ltp/getpgid02 \
+	winsup.api/ltp/getpgrp01 \
+	winsup.api/ltp/getpid01 \
+	winsup.api/ltp/getpid02 \
+	winsup.api/ltp/getppid01 \
+	winsup.api/ltp/getppid02 \
+	winsup.api/ltp/getuid01 \
+	winsup.api/ltp/getuid02 \
+	winsup.api/ltp/getuid03 \
+	winsup.api/ltp/kill01 \
+	winsup.api/ltp/kill02 \
+	winsup.api/ltp/kill03 \
+	winsup.api/ltp/kill04 \
+	winsup.api/ltp/kill09 \
+	winsup.api/ltp/link02 \
+	winsup.api/ltp/link03 \
+	winsup.api/ltp/link04 \
+	winsup.api/ltp/link05 \
+	winsup.api/ltp/lseek01 \
+	winsup.api/ltp/lseek02 \
+	winsup.api/ltp/lseek03 \
+	winsup.api/ltp/lseek04 \
+	winsup.api/ltp/lseek05 \
+	winsup.api/ltp/lseek06 \
+	winsup.api/ltp/lseek07 \
+	winsup.api/ltp/lseek08 \
+	winsup.api/ltp/lseek09 \
+	winsup.api/ltp/lseek10 \
+	winsup.api/ltp/lstat02 \
+	winsup.api/ltp/mkdir01 \
+	winsup.api/ltp/mkdir08 \
+	winsup.api/ltp/mknod01 \
+	winsup.api/ltp/mmap001 \
+	winsup.api/ltp/mmap02 \
+	winsup.api/ltp/mmap03 \
+	winsup.api/ltp/mmap04 \
+	winsup.api/ltp/mmap05 \
+	winsup.api/ltp/mmap06 \
+	winsup.api/ltp/mmap07 \
+	winsup.api/ltp/mmap08 \
+	winsup.api/ltp/munmap01 \
+	winsup.api/ltp/munmap02 \
+	winsup.api/ltp/nice05 \
+	winsup.api/ltp/open02 \
+	winsup.api/ltp/open03 \
+	winsup.api/ltp/pathconf01 \
+	winsup.api/ltp/pause01 \
+	winsup.api/ltp/pipe01 \
+	winsup.api/ltp/pipe08 \
+	winsup.api/ltp/pipe09 \
+	winsup.api/ltp/pipe10 \
+	winsup.api/ltp/pipe11 \
+	winsup.api/ltp/poll01 \
+	winsup.api/ltp/read01 \
+	winsup.api/ltp/read04 \
+	winsup.api/ltp/readdir01 \
+	winsup.api/ltp/readlink01 \
+	winsup.api/ltp/readlink02 \
+	winsup.api/ltp/readlink03 \
+	winsup.api/ltp/rename01 \
+	winsup.api/ltp/rename02 \
+	winsup.api/ltp/rename08 \
+	winsup.api/ltp/rename10 \
+	winsup.api/ltp/rmdir01 \
+	winsup.api/ltp/rmdir04 \
+	winsup.api/ltp/rmdir05 \
+	winsup.api/ltp/sbrk01 \
+	winsup.api/ltp/select01 \
+	winsup.api/ltp/select02 \
+	winsup.api/ltp/select03 \
+	winsup.api/ltp/setgid01 \
+	winsup.api/ltp/setgroups01 \
+	winsup.api/ltp/setpgid01 \
+	winsup.api/ltp/setregid01 \
+	winsup.api/ltp/setreuid01 \
+	winsup.api/ltp/setuid01 \
+	winsup.api/ltp/setuid02 \
+	winsup.api/ltp/signal03 \
+	winsup.api/ltp/stat01 \
+	winsup.api/ltp/stat02 \
+	winsup.api/ltp/stat03 \
+	winsup.api/ltp/stat05 \
+	winsup.api/ltp/stat06 \
+	winsup.api/ltp/symlink01 \
+	winsup.api/ltp/symlink02 \
+	winsup.api/ltp/symlink03 \
+	winsup.api/ltp/symlink04 \
+	winsup.api/ltp/symlink05 \
+	winsup.api/ltp/sync01 \
+	winsup.api/ltp/sync02 \
+	winsup.api/ltp/time01 \
+	winsup.api/ltp/time02 \
+	winsup.api/ltp/times01 \
+	winsup.api/ltp/times02 \
+	winsup.api/ltp/times03 \
+	winsup.api/ltp/truncate01 \
+	winsup.api/ltp/truncate02 \
+	winsup.api/ltp/umask01 \
+	winsup.api/ltp/umask02 \
+	winsup.api/ltp/umask03 \
+	winsup.api/ltp/uname01 \
+	winsup.api/ltp/unlink05 \
+	winsup.api/ltp/unlink06 \
+	winsup.api/ltp/unlink07 \
+	winsup.api/ltp/unlink08 \
+	winsup.api/ltp/vfork01 \
+	winsup.api/ltp/wait02 \
+	winsup.api/ltp/wait401 \
+	winsup.api/ltp/wait402 \
+	winsup.api/ltp/write01 \
+	winsup.api/ltp/write02 \
+	winsup.api/ltp/write03 \
+	winsup.api/pthread/cancel1 \
+	winsup.api/pthread/cancel10 \
+	winsup.api/pthread/cancel11 \
+	winsup.api/pthread/cancel12 \
+	winsup.api/pthread/cancel2 \
+	winsup.api/pthread/cancel3 \
+	winsup.api/pthread/cancel4 \
+	winsup.api/pthread/cancel5 \
+	winsup.api/pthread/cancel6 \
+	winsup.api/pthread/cancel7 \
+	winsup.api/pthread/cancel8 \
+	winsup.api/pthread/cancel9 \
+	winsup.api/pthread/cleanup2 \
+	winsup.api/pthread/cleanup3 \
+	winsup.api/pthread/condvar1 \
+	winsup.api/pthread/condvar2 \
+	winsup.api/pthread/condvar2_1 \
+	winsup.api/pthread/condvar3 \
+	winsup.api/pthread/condvar3_1 \
+	winsup.api/pthread/condvar3_2 \
+	winsup.api/pthread/condvar3_3 \
+	winsup.api/pthread/condvar4 \
+	winsup.api/pthread/condvar5 \
+	winsup.api/pthread/condvar6 \
+	winsup.api/pthread/condvar7 \
+	winsup.api/pthread/condvar8 \
+	winsup.api/pthread/condvar9 \
+	winsup.api/pthread/count1 \
+	winsup.api/pthread/create1 \
+	winsup.api/pthread/create2 \
+	winsup.api/pthread/equal1 \
+	winsup.api/pthread/exit1 \
+	winsup.api/pthread/exit2 \
+	winsup.api/pthread/exit3 \
+	winsup.api/pthread/inherit1 \
+	winsup.api/pthread/join0 \
+	winsup.api/pthread/join1 \
+	winsup.api/pthread/join2 \
+	winsup.api/pthread/mainthreadexits \
+	winsup.api/pthread/mutex1 \
+	winsup.api/pthread/mutex1d \
+	winsup.api/pthread/mutex1e \
+	winsup.api/pthread/mutex1n \
+	winsup.api/pthread/mutex1r \
+	winsup.api/pthread/mutex2 \
+	winsup.api/pthread/mutex3 \
+	winsup.api/pthread/mutex4 \
+	winsup.api/pthread/mutex5 \
+	winsup.api/pthread/mutex6d \
+	winsup.api/pthread/mutex6e \
+	winsup.api/pthread/mutex6n \
+	winsup.api/pthread/mutex6r \
+	winsup.api/pthread/mutex7 \
+	winsup.api/pthread/mutex7d \
+	winsup.api/pthread/mutex7e \
+	winsup.api/pthread/mutex7n \
+	winsup.api/pthread/mutex7r \
+	winsup.api/pthread/mutex8e \
+	winsup.api/pthread/mutex8n \
+	winsup.api/pthread/mutex8r \
+	winsup.api/pthread/once1 \
+	winsup.api/pthread/priority1 \
+	winsup.api/pthread/priority2 \
+	winsup.api/pthread/rwlock1 \
+	winsup.api/pthread/rwlock2 \
+	winsup.api/pthread/rwlock3 \
+	winsup.api/pthread/rwlock4 \
+	winsup.api/pthread/rwlock5 \
+	winsup.api/pthread/rwlock6 \
+	winsup.api/pthread/rwlock7 \
+	winsup.api/pthread/self1 \
+	winsup.api/pthread/self2 \
+	winsup.api/pthread/threadidafterfork \
+	winsup.api/pthread/tsd1 \
+	winsup.api/samples/sample-fail \
+	winsup.api/samples/sample-pass
+# winsup.api/ltp/ulimit01 is omitted as we don't have <ulimit.h>
+
+# flags for linking against the just built implib
+# TODO: use -nostdinc and to-be-installed headers as well?
+LDFLAGS_FOR_TESTDLL = -nodefaultlibs
+LDADD_FOR_TESTDLL = $(builddir)/../cygwin/libcygwin.a -lgcc -lkernel32 -luser32
+
+# flags for test executables
+AM_CPPFLAGS = -I$(srcdir)/libltp/include
+AM_LDFLAGS = $(LDFLAGS_FOR_TESTDLL)
+LDADD = $(builddir)/libltp.a $(builddir)/../cygwin/binmode.o $(LDADD_FOR_TESTDLL)
+
 DEJATOOL = winsup
 
 # Add '-v' to RUNTESTFLAGS if V=1
@@ -46,22 +340,19 @@ testdll_tmpdir = $(shell cygpath -ma $(tmpdir) | sed -e 's#^\([A-Z]\):#/cygdrive
 site-extra.exp: ../config.status Makefile
 	@rm -f ./tmp0
 	@echo "set runtime_root \"`pwd`/runtime\"" >> ./tmp0
-	@echo "set libdir \"`pwd`/../cygwin\"" >> ./tmp0
-	@echo "set CC \"$(CC)\"" >> ./tmp0
-	@echo "set CFLAGS \"\"" >> ./tmp0
-	@echo "set MINGW_CXX \"$(MINGW_CXX)\"" >> ./tmp0
 	@echo "set tmpdir $(tmpdir)" >> ./tmp0
 	@echo "set testdll_tmpdir $(testdll_tmpdir)" >> ./tmp0
-	@echo "set ltp_includes \"$(srcdir)/libltp/include\"" >> ./tmp0
-	@echo "set ltp_libs \"`pwd`/libltp.a\"" >> ./tmp0
-	@echo "set cygrun \"`pwd`/cygrun/cygrun\"" >> ./tmp0
+	@echo "set cygrun \"`pwd`/mingw/cygrun\"" >> ./tmp0
 	@mv ./tmp0 site-extra.exp
 
 EXTRA_DEJAGNU_SITE_CONFIG = site-extra.exp
 
+# target to build all the programs needed by check, without running check
+check_programs: $(check_PROGRAMS)
+
 clean-local:
 	rm -f *.log *.exe *.exp *.bak *.stackdump winsup.sum
 
 if CROSS_BOOTSTRAP
-SUBDIRS = cygrun
+SUBDIRS = mingw
 endif
diff --git a/winsup/testsuite/README b/winsup/testsuite/README
index c22b06594..363ebb9e8 100644
--- a/winsup/testsuite/README
+++ b/winsup/testsuite/README
@@ -21,7 +21,7 @@ cygwin1.dll ONLY.  Create other subdirs under testsuite/ for other
 classes of testing.
 
 Tests in winsup.api/*.c or winsup.api/*/*.c (only one subdirectory
-level is allowed) either compile, run, and exit(0) or they fail.
+level is allowed) either run, and exit(0) or they fail.
 Either abort or exit with a non-zero code to indicate failure.  Don't
 print anything to the screen if you can avoid it (except for failure
 reasons, of course).  One .c file per test, no compile options are
diff --git a/winsup/testsuite/cygrun/Makefile.am b/winsup/testsuite/mingw/Makefile.am
similarity index 58%
rename from winsup/testsuite/cygrun/Makefile.am
rename to winsup/testsuite/mingw/Makefile.am
index bdbd8f705..772e73405 100644
--- a/winsup/testsuite/cygrun/Makefile.am
+++ b/winsup/testsuite/mingw/Makefile.am
@@ -1,4 +1,4 @@
-# Makefile.am for Cygwin the testsuite wrapper cygrun.
+# Makefile.am for Cygwin testsuite MINGW executables
 #
 # This file is part of Cygwin.
 #
@@ -8,14 +8,19 @@
 
 # This makefile requires GNU make.
 
-# This is built with the MinGW compiler, so is in a separate Makefile here
+# These are built with the MinGW compiler, so are in a separate Makefile here
 # because it's tricky with Automake to use different compilers for the same
 # language in the same Makefile.
 
 override CC = @MINGW_CC@
+override CXX = @MINGW_CXX@
 AM_CPPFLAGS =
 
-noinst_PROGRAMS = cygrun
+noinst_PROGRAMS = cygrun cygload
 
 cygrun_SOURCES = \
 	../cygrun.c
+
+cygload_SOURCES = \
+	../winsup.api/cygload.cc
+cygload_LDFLAGS=-static -Wl,-e,cygloadCRTStartup
diff --git a/winsup/testsuite/winsup.api/cygload.exp b/winsup/testsuite/winsup.api/cygload.exp
index e378820ad..724cb01cc 100644
--- a/winsup/testsuite/winsup.api/cygload.exp
+++ b/winsup/testsuite/winsup.api/cygload.exp
@@ -14,33 +14,17 @@ proc ws_spawn {cmd args} {
     verbose send "catchCode = $rv\n"
 }
 
-if { [string match "i686" $target_alias] } {
-    set entrypoint "_cygloadCRTStartup@0"
+if { $verbose } {
+    set redirect_output "./mingw-cygwin.log"
 } else {
-    set entrypoint "cygloadCRTStartup"
+    set redirect_output /dev/null
 }
 
-ws_spawn "$MINGW_CXX $srcdir/$subdir/cygload.cc -o mingw-cygload.exe -static -Wl,-e,$entrypoint"
-
+set windows_runtime_root [exec cygpath -m $runtime_root]
+ws_spawn "./mingw/cygload.exe -cygwin $windows_runtime_root/cygwin1.dll > $redirect_output"
 if { $rv != {0 {}} } {
-    verbose -log "$rv"
-    fail "cygload (compile)"
+    verbose -log "cygload: $rv"
+    fail "cygload"
 } else {
-    if { $verbose } {
-        set redirect_output "./mingw-cygwin.log"
-    } else {
-        set redirect_output /dev/null
-    }
-    set windows_runtime_root [exec cygpath -m $runtime_root]
-    ws_spawn "./mingw-cygload.exe -cygwin $windows_runtime_root/cygwin1.dll > $redirect_output"
-    if { $rv != {0 {}} } {
-        verbose -log "cygload: $rv"
-        fail "cygload (execute)"
-    } else {
-        pass "cygload"
-    }
-    catch { file delete "mingw-cygload.exe" } err
-    if { $err != "" } {
-        note "error deleting mingw-cygload.exe: $err"
-    }
+    pass "cygload"
 }
diff --git a/winsup/testsuite/winsup.api/samples/sample-miscompile.c b/winsup/testsuite/winsup.api/samples/sample-miscompile.c
deleted file mode 100644
index bc0d21d2e..000000000
--- a/winsup/testsuite/winsup.api/samples/sample-miscompile.c
+++ /dev/null
@@ -1 +0,0 @@
-foo bar grill
diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp
index e81ead304..fb3e3816c 100644
--- a/winsup/testsuite/winsup.api/winsup.exp
+++ b/winsup/testsuite/winsup.api/winsup.exp
@@ -8,12 +8,6 @@ if { ! [isnative] } {
 
 set rv ""
 
-set ltp_includes "-I$ltp_includes"
-set ltp_libs "$ltp_libs"
-
-set add_includes $ltp_includes
-set add_libs $ltp_libs
-
 set orig_path "$env(PATH)"
 
 set test_filter ""
@@ -48,7 +42,9 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
     regsub "^$srcdir/$subdir/" $src "" testcase
     regsub ".c$" $testcase "" base
     regsub ".*/" $base "" basename
-    regsub "/" $base "-" base
+    regsub "/" $base "-" tmpfile
+
+    set exec "./winsup.api/$base.exe"
 
     if { [lsearch -exact $xfail_list $basename] >= 0 } {
         set xfail_expected 1
@@ -61,37 +57,20 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
     if [ file exists "$srcdir/$subdir/$basename.exp" ] then {
 	source "$srcdir/$subdir/$basename.exp"
     } else {
-	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $libdir/binmode.o -lgcc $libdir/libcygwin.a -lkernel32 -luser32 -o $base.exe"
-	if { $rv } {
-	    fail "$testcase (compile)"
-	} else {
 	    if { $verbose } {
-	       set redirect_output "./$base.log"
+	       set redirect_output "./$tmpfile.log"
 	    } else {
 	       set redirect_output /dev/null
 	    }
-	    file mkdir $tmpdir/$base
+	    file mkdir $tmpdir/$tmpfile
 	    set env(PATH) "$runtime_root:$env(PATH)"
-	    ws_spawn "$cygrun ./$base.exe $testdll_tmpdir/$base > $redirect_output"
-	    file delete -force $tmpdir/$base
+	    ws_spawn "$cygrun $exec $testdll_tmpdir/$tmpfile > $redirect_output"
+	    file delete -force $tmpdir/$tmpfile
 	    set env(PATH) "$orig_path"
 	    if { $rv } {
-		fail "$testcase (execute)"
-		if { $xfail_expected } {
-		    catch { file delete "$base.exe" } err
-		    if { $err != "" } {
-			note "error deleting $base.exe: $err"
-		    }
-		}
+		fail "$testcase"
 	    } else {
 		pass "$testcase"
-		if { ! $xfail_expected } {
-		    catch { file delete "$base.exe" } err
-		    if { $err != "" } {
-			note "error deleting $base.exe: $err"
-		    }
-		}
 	    }
-	}
     }
 }
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/8] Cygwin: testsuite: Fix compilation warnings
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
  2023-01-10 16:37 ` [PATCH 1/8] Cygwin: testsuite: automake doesn't define objdir Jon Turney
  2023-01-10 16:37 ` [PATCH 2/8] Cygwin: testsuite: Build testcases using automake Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 4/8] Cygwin: testsuite: 64-bit fixes in pthread testcases Jon Turney
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Fix the warnings the previous change surfaces.

See ltp commit d5c2112f for mmap fixes.
---
 winsup/testsuite/libltp/include/usctest.h  |  2 +-
 winsup/testsuite/winsup.api/ltp/execv01.c  |  2 +-
 winsup/testsuite/winsup.api/ltp/execve01.c |  2 +-
 winsup/testsuite/winsup.api/ltp/execvp01.c |  2 +-
 winsup/testsuite/winsup.api/ltp/mmap02.c   | 10 ++++------
 winsup/testsuite/winsup.api/ltp/mmap03.c   | 10 ++++------
 winsup/testsuite/winsup.api/ltp/mmap04.c   | 10 ++++------
 winsup/testsuite/winsup.api/ltp/mmap05.c   | 10 +++++-----
 winsup/testsuite/winsup.api/ltp/mmap06.c   |  8 +++++---
 winsup/testsuite/winsup.api/ltp/mmap07.c   |  8 +++++---
 winsup/testsuite/winsup.api/ltp/mmap08.c   |  8 +++++---
 winsup/testsuite/winsup.api/mmaptest03.c   |  2 +-
 winsup/testsuite/winsup.api/systemcall.c   |  2 +-
 winsup/testsuite/winsup.api/user_malloc.c  |  4 ++--
 14 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/winsup/testsuite/libltp/include/usctest.h b/winsup/testsuite/libltp/include/usctest.h
index fef349d04..637635a25 100644
--- a/winsup/testsuite/libltp/include/usctest.h
+++ b/winsup/testsuite/libltp/include/usctest.h
@@ -210,7 +210,7 @@ extern void STD_opts_help();
  *	SCALL = system call and parameters to execute
  *
  ***********************************************************************/
-#define TEST(SCALL) TEST_RETURN = SCALL;  TEST_ERRNO=errno;
+#define TEST(SCALL) TEST_RETURN = (long) SCALL;  TEST_ERRNO=errno;
 
 /***********************************************************************
  * TEST_VOID: calls a system call
diff --git a/winsup/testsuite/winsup.api/ltp/execv01.c b/winsup/testsuite/winsup.api/ltp/execv01.c
index f59f29702..dca62c523 100644
--- a/winsup/testsuite/winsup.api/ltp/execv01.c
+++ b/winsup/testsuite/winsup.api/ltp/execv01.c
@@ -130,7 +130,7 @@ int exp_enos[]={0, 0};		/* Zero terminated list of expected errnos */
 
 int pid;		/* process id from fork */
 int status;		/* status returned from waitpid */
-const char * const args[2]={"/usr/bin/test", 0};	/* argument list for execv call */
+char * const args[2]={"/usr/bin/test", 0};	/* argument list for execv call */
 
 int
 main(int ac, char **av)
diff --git a/winsup/testsuite/winsup.api/ltp/execve01.c b/winsup/testsuite/winsup.api/ltp/execve01.c
index 2584bdf05..eb5073d31 100644
--- a/winsup/testsuite/winsup.api/ltp/execve01.c
+++ b/winsup/testsuite/winsup.api/ltp/execve01.c
@@ -133,7 +133,7 @@ int exp_enos[]={0, 0};		/* Zero terminated list of expected errnos */
 
 int pid;			/* process id from fork */
 int status;			/* status returned from waitpid */
-const char *const args[2]={"/usr/bin/test", 0};	/* argument list for execve call */
+char *const args[2]={"/usr/bin/test", 0};	/* argument list for execve call */
 extern char **environ;		/* pointer to this processes env, to pass along */
 
 int
diff --git a/winsup/testsuite/winsup.api/ltp/execvp01.c b/winsup/testsuite/winsup.api/ltp/execvp01.c
index 8a1726a21..1473ccf66 100644
--- a/winsup/testsuite/winsup.api/ltp/execvp01.c
+++ b/winsup/testsuite/winsup.api/ltp/execvp01.c
@@ -133,7 +133,7 @@ int exp_enos[]={0, 0};		/* Zero terminated list of expected errnos */
 
 int pid;		/* process id from fork */
 int status;		/* status returned from waitpid */
-const char *const args[2]={"/usr/bin/test", 0};	/* argument list for execvp call */
+char *const args[2]={"/usr/bin/test", 0};	/* argument list for execvp call */
 
 int
 main(int ac, char **av)
diff --git a/winsup/testsuite/winsup.api/ltp/mmap02.c b/winsup/testsuite/winsup.api/ltp/mmap02.c
index b96bdb452..ca9f4d956 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap02.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap02.c
@@ -118,11 +118,12 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with read access.
 		 */
-		TEST(mmap(0, page_sz, PROT_READ,
-			    MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_READ,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN == (int)MAP_FAILED) {
+		if (addr == MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s",
 				 TEMPFILE, errno, strerror(errno));
 			continue;
@@ -132,9 +133,6 @@ main(int ac, char **av)
 		 * executed without (-f) option.
 		 */
 		if (STD_FUNCTIONAL_TEST) {
-			/* Get the mmap return value */
-			addr = (char *)TEST_RETURN;
-
 			/*
 			 * Read the file contents into the dummy
 			 * string.
diff --git a/winsup/testsuite/winsup.api/ltp/mmap03.c b/winsup/testsuite/winsup.api/ltp/mmap03.c
index fba512c28..5de5435d3 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap03.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap03.c
@@ -121,11 +121,12 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with execute access.
 		 */
-		TEST(mmap(0, page_sz, PROT_EXEC,
-			    MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_EXEC,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN == (int)MAP_FAILED) {
+		if (addr == MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s",
 				 TEMPFILE, errno, strerror(errno));
 			continue;
@@ -135,9 +136,6 @@ main(int ac, char **av)
 		 * executed without (-f) option.
 		 */
 		if (STD_FUNCTIONAL_TEST) {
-			/* Get the mmap return value */
-			addr = (char *)TEST_RETURN;
-
 			/*
 			 * Read the file contents into the dummy
 			 * variable.
diff --git a/winsup/testsuite/winsup.api/ltp/mmap04.c b/winsup/testsuite/winsup.api/ltp/mmap04.c
index dbe25aefd..e69d15a97 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap04.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap04.c
@@ -121,11 +121,12 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with read and execute access.
 		 */
-		TEST(mmap(0, page_sz, PROT_READ|PROT_EXEC,
-			    MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_READ|PROT_EXEC,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN == (int)MAP_FAILED) {
+		if (addr == MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s",
 				 TEMPFILE, errno, strerror(errno));
 			continue;
@@ -136,9 +137,6 @@ main(int ac, char **av)
 		 * executed without (-f) option.
 		 */
 		if (STD_FUNCTIONAL_TEST) {
-			/* Get the mmap return value */
-			addr = (char *)TEST_RETURN;
-
 			/*
 			 * Read the file contents into the dummy
 			 * variable.
diff --git a/winsup/testsuite/winsup.api/ltp/mmap05.c b/winsup/testsuite/winsup.api/ltp/mmap05.c
index 6e75ee222..600cd761e 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap05.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap05.c
@@ -125,12 +125,12 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with no access.
 		 */
-		
-		TEST(mmap(0, page_sz, PROT_NONE,
-			  MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_NONE,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN == (int)MAP_FAILED) {
+		if (addr == MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s",
 				 TEMPFILE, errno, strerror(errno));
 			continue;
@@ -264,7 +264,7 @@ setup()
  *   is not accessible.
  */
 void
-sig_handler(sig)
+sig_handler(int sig)
 {
 	if (sig == SIGSEGV) {
 		/* set the global variable and jump back */
diff --git a/winsup/testsuite/winsup.api/ltp/mmap06.c b/winsup/testsuite/winsup.api/ltp/mmap06.c
index c099f8c33..d089f900b 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap06.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap06.c
@@ -121,11 +121,13 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with read access.
 		 */
-		TEST(mmap(0, page_sz, PROT_READ,
-			    MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_READ,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
+		TEST_ERRNO = errno;
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN != (int)MAP_FAILED) {
+		if (addr != MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() returned invalid value, "
 				 "expected: -1");
 			/* Unmap the mapped memory */
diff --git a/winsup/testsuite/winsup.api/ltp/mmap07.c b/winsup/testsuite/winsup.api/ltp/mmap07.c
index 6e3bb5112..4be6129e6 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap07.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap07.c
@@ -122,11 +122,13 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * with write access.
 		 */
-		TEST(mmap(0, page_sz, PROT_WRITE,
-			    MAP_FILE|MAP_PRIVATE, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_WRITE,
+			    MAP_FILE|MAP_PRIVATE, fildes, 0);
+		TEST_ERRNO = errno;
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN != (int)MAP_FAILED) {
+		if (addr != MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() returned invalid value, "
 				 "expected: -1");
 			/* Unmap the mapped memory */
diff --git a/winsup/testsuite/winsup.api/ltp/mmap08.c b/winsup/testsuite/winsup.api/ltp/mmap08.c
index 543c5397b..49b6471e5 100644
--- a/winsup/testsuite/winsup.api/ltp/mmap08.c
+++ b/winsup/testsuite/winsup.api/ltp/mmap08.c
@@ -117,11 +117,13 @@ main(int ac, char **av)
 		 * Call mmap to map the temporary file 'TEMPFILE'
 	 	 * which is already closed. so, fildes is not valid.
 		 */
-		TEST(mmap(0, page_sz, PROT_WRITE,
-			    MAP_FILE|MAP_SHARED, fildes, 0));
+		errno = 0;
+		addr = mmap(0, page_sz, PROT_WRITE,
+			    MAP_FILE|MAP_SHARED, fildes, 0);
+		TEST_ERRNO = errno;
 
 		/* Check for the return value of mmap() */
-		if (TEST_RETURN != (int)MAP_FAILED) {
+		if (addr != MAP_FAILED) {
 			tst_resm(TFAIL, "mmap() returned invalid value, "
 				 "expected: -1");
 			/* Unmap the mapped memory */
diff --git a/winsup/testsuite/winsup.api/mmaptest03.c b/winsup/testsuite/winsup.api/mmaptest03.c
index 8046f0bf8..e28e0f251 100644
--- a/winsup/testsuite/winsup.api/mmaptest03.c
+++ b/winsup/testsuite/winsup.api/mmaptest03.c
@@ -145,7 +145,7 @@ main(int argc, char **argv)
       unlink ("y.txt");
       if (!WIFEXITED (status) || WEXITSTATUS (status))
 	{
-	  printf ("forked process exited with status %p\n", (char *) status);
+	  printf ("forked process exited with status %x\n", status);
 	  return 1;
 	}
     }
diff --git a/winsup/testsuite/winsup.api/systemcall.c b/winsup/testsuite/winsup.api/systemcall.c
index 91dd748c0..d10c9825c 100644
--- a/winsup/testsuite/winsup.api/systemcall.c
+++ b/winsup/testsuite/winsup.api/systemcall.c
@@ -61,7 +61,7 @@ main (int argc, char **argv)
     }
   if (n != 0)
     {
-      fprintf (stderr, "system() call returned %p\n", (void *) n);
+      fprintf (stderr, "system() call returned %x\n", n);
       exit (1);
     }
   exit (0);
diff --git a/winsup/testsuite/winsup.api/user_malloc.c b/winsup/testsuite/winsup.api/user_malloc.c
index 8685f86ab..e2b1e0a92 100644
--- a/winsup/testsuite/winsup.api/user_malloc.c
+++ b/winsup/testsuite/winsup.api/user_malloc.c
@@ -133,11 +133,11 @@ ull * current = buffer;
 
 static int is_valid (void * ptr)
 {
-  unsigned int iptr = (unsigned int) ptr;
+  uintptr_t iptr = (uintptr_t) ptr;
   ull * ullptr = (ull *) ptr;
 
   iptr = (iptr / sizeof(ull)) * sizeof(ull);
-  if (iptr != (int) ptr)
+  if (iptr != (uintptr_t) ptr)
     return 0;
   if (--ullptr < buffer || ullptr[0] > SIZE || ullptr  + ullptr[0]  > current)
     return 0;
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/8] Cygwin: testsuite: 64-bit fixes in pthread testcases
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
                   ` (2 preceding siblings ...)
  2023-01-10 16:37 ` [PATCH 3/8] Cygwin: testsuite: Fix compilation warnings Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 5/8] Cygwin: testsuite: Update mutex tests for changed default mutex type Jon Turney
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Fix warnings and 64-bit issues in pthread testcases.

See pthread-win32 commit 1183e5ac etc.
---
 winsup/testsuite/winsup.api/pthread/cancel2.c | 10 ++++-----
 winsup/testsuite/winsup.api/pthread/cancel3.c | 10 ++++-----
 winsup/testsuite/winsup.api/pthread/cancel4.c | 10 ++++-----
 winsup/testsuite/winsup.api/pthread/cancel5.c | 12 +++++-----
 .../testsuite/winsup.api/pthread/cleanup2.c   | 10 ++++-----
 .../testsuite/winsup.api/pthread/cleanup3.c   |  8 +++----
 .../testsuite/winsup.api/pthread/condvar2_1.c | 12 +++++-----
 .../testsuite/winsup.api/pthread/condvar3_1.c | 12 +++++-----
 .../testsuite/winsup.api/pthread/condvar3_2.c | 14 ++++++------
 winsup/testsuite/winsup.api/pthread/exit3.c   |  2 +-
 .../testsuite/winsup.api/pthread/inherit1.c   |  4 ++--
 winsup/testsuite/winsup.api/pthread/join1.c   | 10 ++++-----
 winsup/testsuite/winsup.api/pthread/join2.c   |  8 +++----
 winsup/testsuite/winsup.api/pthread/mutex4.c  |  2 +-
 .../testsuite/winsup.api/pthread/priority1.c  |  4 ++--
 .../testsuite/winsup.api/pthread/priority2.c  |  4 ++--
 winsup/testsuite/winsup.api/pthread/rwlock6.c | 22 +++++++++----------
 17 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/winsup/testsuite/winsup.api/pthread/cancel2.c b/winsup/testsuite/winsup.api/pthread/cancel2.c
index 14889313e..19902dc0f 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel2.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel2.c
@@ -96,7 +96,7 @@ mythread(void * arg)
       pthread_testcancel();
     }
 
-  return (void *) result;
+  return (void *) (size_t)result;
 }
 
 int
@@ -156,17 +156,17 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void *result = 0;
 
-      assert(pthread_join(t[i], (void **) &result) == 0);
-      fail = (result != (int) PTHREAD_CANCELED);
+      assert(pthread_join(t[i], &result) == 0);
+      fail = (result != PTHREAD_CANCELED);
       if (fail)
 	{
 	  fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n",
 		  i,
 		  threadbag[i].started,
 		  result,
-		  ((result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED");
+		  (((int)(size_t)result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED");
 	}
       failed |= fail;
     }
diff --git a/winsup/testsuite/winsup.api/pthread/cancel3.c b/winsup/testsuite/winsup.api/pthread/cancel3.c
index 3ac03e4b6..832fe2e3f 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel3.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel3.c
@@ -61,7 +61,7 @@ static bag_t threadbag[NUMTHREADS + 1];
 void *
 mythread(void * arg)
 {
-  int result = ((int)PTHREAD_CANCELED + 1);
+  void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
   bag_t * bag = (bag_t *) arg;
 
   assert(bag == &threadbag[bag->threadnum]);
@@ -81,7 +81,7 @@ mythread(void * arg)
   for (bag->count = 0; bag->count < 100; bag->count++)
     Sleep(100);
 
-  return (void *) result;
+  return result;
 }
 
 int
@@ -136,16 +136,16 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void *result = 0;
 
       /*
        * The thread does not contain any cancelation points, so
        * a return value of PTHREAD_CANCELED confirms that async
        * cancelation succeeded.
        */
-      assert(pthread_join(t[i], (void **) &result) == 0);
+      assert(pthread_join(t[i], &result) == 0);
 
-      fail = (result != (int) PTHREAD_CANCELED);
+      fail = (result != PTHREAD_CANCELED);
 
       if (fail)
 	{
diff --git a/winsup/testsuite/winsup.api/pthread/cancel4.c b/winsup/testsuite/winsup.api/pthread/cancel4.c
index d6b2ffadf..d8151891b 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel4.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel4.c
@@ -66,7 +66,7 @@ static bag_t threadbag[NUMTHREADS + 1];
 void *
 mythread(void * arg)
 {
-  int result = ((int)PTHREAD_CANCELED + 1);
+  void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
   bag_t * bag = (bag_t *) arg;
 
   assert(bag == &threadbag[bag->threadnum]);
@@ -86,7 +86,7 @@ mythread(void * arg)
   for (bag->count = 0; bag->count < 100; bag->count++)
     Sleep(100);
 
-  return (void *) result;
+  return result;
 }
 
 int
@@ -141,16 +141,16 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void* result = 0;
 
       /*
        * The thread does not contain any cancelation points, so
        * a return value of PTHREAD_CANCELED indicates that async
        * cancelation occurred.
        */
-      assert(pthread_join(t[i], (void **) &result) == 0);
+      assert(pthread_join(t[i], &result) == 0);
 
-      fail = (result == (int) PTHREAD_CANCELED);
+      fail = (result == PTHREAD_CANCELED);
 
       if (fail)
 	{
diff --git a/winsup/testsuite/winsup.api/pthread/cancel5.c b/winsup/testsuite/winsup.api/pthread/cancel5.c
index 9dd579543..8b7240615 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel5.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel5.c
@@ -62,7 +62,7 @@ static bag_t threadbag[NUMTHREADS + 1];
 void *
 mythread(void * arg)
 {
-  int result = ((int)PTHREAD_CANCELED + 1);
+  void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
   bag_t * bag = (bag_t *) arg;
 
   assert(bag == &threadbag[bag->threadnum]);
@@ -82,7 +82,7 @@ mythread(void * arg)
   for (bag->count = 0; bag->count < 100; bag->count++)
     Sleep(100);
 
-  return (void *) result;
+  return result;
 }
 
 int
@@ -96,7 +96,7 @@ main()
     {
       threadbag[i].started = 0;
       threadbag[i].threadnum = i;
-      assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0);
+      assert(pthread_create(&t[i], NULL, mythread, &threadbag[i]) == 0);
     }
 
   /*
@@ -135,16 +135,16 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1);
 
       /*
        * The thread does not contain any cancelation points, so
        * a return value of PTHREAD_CANCELED confirms that async
        * cancelation succeeded.
        */
-      assert(pthread_join(t[i], (void **) &result) == 0);
+      assert(pthread_join(t[i], &result) == 0);
 
-      fail = (result != (int) PTHREAD_CANCELED);
+      fail = (result != PTHREAD_CANCELED);
 
       if (fail)
 	{
diff --git a/winsup/testsuite/winsup.api/pthread/cleanup2.c b/winsup/testsuite/winsup.api/pthread/cleanup2.c
index bcbaad3a7..75c239a00 100644
--- a/winsup/testsuite/winsup.api/pthread/cleanup2.c
+++ b/winsup/testsuite/winsup.api/pthread/cleanup2.c
@@ -84,7 +84,7 @@ mythread(void * arg)
 
   pthread_cleanup_pop(1);
 
-  return (void *) result;
+  return (void *) (size_t) result;
 }
 
 int
@@ -129,18 +129,18 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void* result = 0;
 
-      assert(pthread_join(t[i], (void **) &result) == 0);
+      assert(pthread_join(t[i], &result) == 0);
 
-      fail = (result != 0);
+      fail = ((int)(size_t)result != 0);
 
       if (fail)
 	{
 	  fprintf(stderr, "Thread %d: started %d: result: %d\n",
 		  i,
 		  threadbag[i].started,
-		  result);
+		  (int)(size_t)result);
 	}
       failed = (failed || fail);
     }
diff --git a/winsup/testsuite/winsup.api/pthread/cleanup3.c b/winsup/testsuite/winsup.api/pthread/cleanup3.c
index f8201faa0..6fea8dc93 100644
--- a/winsup/testsuite/winsup.api/pthread/cleanup3.c
+++ b/winsup/testsuite/winsup.api/pthread/cleanup3.c
@@ -87,7 +87,7 @@ mythread(void * arg)
 
   pthread_cleanup_pop(0);
 
-  return (void *) result;
+  return (void *) (size_t)result;
 }
 
 int
@@ -132,9 +132,9 @@ main()
   for (i = 1; i <= NUMTHREADS; i++)
     {
       int fail = 0;
-      int result = 0;
+      void* result = 0;
 
-      assert(pthread_join(t[i], (void **) &result) == 0);
+      assert(pthread_join(t[i], &result) == 0);
 
       fail = (result != 0);
 
@@ -143,7 +143,7 @@ main()
 	  fprintf(stderr, "Thread %d: started %d: result: %d\n",
 		  i,
 		  threadbag[i].started,
-		  result);
+		  (int)(size_t)result);
 	}
       failed = (failed || fail);
     }
diff --git a/winsup/testsuite/winsup.api/pthread/condvar2_1.c b/winsup/testsuite/winsup.api/pthread/condvar2_1.c
index da3416203..1aa4fed9a 100644
--- a/winsup/testsuite/winsup.api/pthread/condvar2_1.c
+++ b/winsup/testsuite/winsup.api/pthread/condvar2_1.c
@@ -69,7 +69,7 @@ main()
 {
   int i;
   pthread_t t[NUMTHREADS + 1];
-  int result = 0;
+  void* result = 0;
   struct timeb currSysTime;
   const DWORD NANOSEC_PER_MILLISEC = 1000000;
 
@@ -89,19 +89,19 @@ main()
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0);
+      assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0);
     }
 
   assert(pthread_mutex_unlock(&mutex) == 0);
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_join(t[i], (void **) &result) == 0);
-      assert(result == i);
+      assert(pthread_join(t[i], &result) == 0);
+      assert((int)(size_t)result == i);
     }
 
-  result = pthread_cond_destroy(&cv);
-  assert(result == 0);
+  int result2 = pthread_cond_destroy(&cv);
+  assert(result2 == 0);
 
   return 0;
 }
diff --git a/winsup/testsuite/winsup.api/pthread/condvar3_1.c b/winsup/testsuite/winsup.api/pthread/condvar3_1.c
index b08b04889..a4653ebc8 100644
--- a/winsup/testsuite/winsup.api/pthread/condvar3_1.c
+++ b/winsup/testsuite/winsup.api/pthread/condvar3_1.c
@@ -89,7 +89,7 @@ main()
 {
   int i;
   pthread_t t[NUMTHREADS + 1];
-  int result = 0;
+  void* result = 0;
   struct timeb currSysTime;
   const DWORD NANOSEC_PER_MILLISEC = 1000000;
 
@@ -110,7 +110,7 @@ main()
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0);
+      assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0);
     }
 
   do {
@@ -127,8 +127,8 @@ main()
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_join(t[i], (void **) &result) == 0);
-        assert(result == i);
+      assert(pthread_join(t[i], &result) == 0);
+      assert((int)(size_t)result == i);
     }
 
   printf("awk = %d\n", awoken);
@@ -138,8 +138,8 @@ main()
   assert(signaled == awoken);
   assert(timedout == NUMTHREADS - signaled);
 
-  result = pthread_cond_destroy(&cv);
-  assert(result == 0);
+  int result2 = pthread_cond_destroy(&cv);
+  assert(result2 == 0);
 
   return 0;
 }
diff --git a/winsup/testsuite/winsup.api/pthread/condvar3_2.c b/winsup/testsuite/winsup.api/pthread/condvar3_2.c
index 57e7eb439..b08d8e256 100644
--- a/winsup/testsuite/winsup.api/pthread/condvar3_2.c
+++ b/winsup/testsuite/winsup.api/pthread/condvar3_2.c
@@ -66,7 +66,7 @@ mythread(void * arg)
 
   abstime2.tv_sec = abstime.tv_sec;
 
-  if ((int) arg % 3 == 0)
+  if ((int) (size_t)arg % 3 == 0)
     {
       abstime2.tv_sec += 2;
     }
@@ -91,7 +91,7 @@ main()
 {
   int i;
   pthread_t t[NUMTHREADS + 1];
-  int result = 0;
+  void* result = 0;
   struct timeb currSysTime;
   const DWORD NANOSEC_PER_MILLISEC = 1000000;
 
@@ -109,15 +109,15 @@ main()
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0);
+      assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0);
     }
 
   assert(pthread_mutex_unlock(&mutex) == 0);
 
   for (i = 1; i <= NUMTHREADS; i++)
     {
-      assert(pthread_join(t[i], (void **) &result) == 0);
-	assert(result == i);
+      assert(pthread_join(t[i], &result) == 0);
+      assert((int)(size_t)result == i);
       /*
        * Approximately 2/3rds of the threads are expected to time out.
        * Signal the remainder after some threads have woken up and exited
@@ -132,8 +132,8 @@ main()
 
   assert(awoken == NUMTHREADS - timedout);
 
-  result = pthread_cond_destroy(&cv);
-  assert(result == 0);
+  int result2 = pthread_cond_destroy(&cv);
+  assert(result2 == 0);
 
   return 0;
 }
diff --git a/winsup/testsuite/winsup.api/pthread/exit3.c b/winsup/testsuite/winsup.api/pthread/exit3.c
index 0b6ec31c5..7baf7bb10 100644
--- a/winsup/testsuite/winsup.api/pthread/exit3.c
+++ b/winsup/testsuite/winsup.api/pthread/exit3.c
@@ -24,7 +24,7 @@ main(int argc, char * argv[])
 	/* Create a few threads and then exit. */
 	for (i = 0; i < 4; i++)
 	  {
-	    assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
+	    assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0);
 	  }
 
 	Sleep(1000);
diff --git a/winsup/testsuite/winsup.api/pthread/inherit1.c b/winsup/testsuite/winsup.api/pthread/inherit1.c
index a909eb763..545e4596f 100644
--- a/winsup/testsuite/winsup.api/pthread/inherit1.c
+++ b/winsup/testsuite/winsup.api/pthread/inherit1.c
@@ -47,7 +47,7 @@ void * func(void * arg)
   struct sched_param param;
 
   assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
-  return (void *) param.sched_priority;
+  return (void *) (size_t)param.sched_priority;
 }
 
 int
@@ -91,7 +91,7 @@ main()
           assert(pthread_attr_setschedparam(&attr, &param) == 0);
           assert(pthread_create(&t, &attr, func, NULL) == 0);
           pthread_join(t, &result);
-          assert((int) result == mainParam.sched_priority);
+          assert((int)(size_t) result == mainParam.sched_priority);
         }
     }
 
diff --git a/winsup/testsuite/winsup.api/pthread/join1.c b/winsup/testsuite/winsup.api/pthread/join1.c
index d74e0c484..8a9d17669 100644
--- a/winsup/testsuite/winsup.api/pthread/join1.c
+++ b/winsup/testsuite/winsup.api/pthread/join1.c
@@ -9,7 +9,7 @@
 void *
 func(void * arg)
 {
-    int i = (int) arg;
+  int i = (int)(size_t)arg;
 
     Sleep(i * 500);
 
@@ -24,12 +24,12 @@ main(int argc, char * argv[])
 {
 	pthread_t id[4];
 	int i;
-	int result;
+	void* result = (void*)-1;
 
 	/* Create a few threads and then exit. */
 	for (i = 0; i < 4; i++)
 	  {
-	    assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
+	    assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0);
 	  }
 
 	/* Some threads will finish before they are joined, some after. */
@@ -37,9 +37,9 @@ main(int argc, char * argv[])
 
 	for (i = 0; i < 4; i++)
 	  {
-	    assert(pthread_join(id[i], (void **) &result) == 0);
+	    assert(pthread_join(id[i], &result) == 0);
 #if ! defined (__MINGW32__) || defined (__MSVCRT__)
-	    assert(result == i);
+	    assert((int)(size_t)result == i);
 #else
 # warning pthread_join not fully supported in this configuration.
 	    assert(result == 0);
diff --git a/winsup/testsuite/winsup.api/pthread/join2.c b/winsup/testsuite/winsup.api/pthread/join2.c
index cdc8ca2d9..9a8de4619 100644
--- a/winsup/testsuite/winsup.api/pthread/join2.c
+++ b/winsup/testsuite/winsup.api/pthread/join2.c
@@ -18,21 +18,21 @@ main(int argc, char * argv[])
 {
 	pthread_t id[4];
 	int i;
-	int result;
+	void* result = (void*)-1;
 
 	/* Create a few threads and then exit. */
 	for (i = 0; i < 4; i++)
 	  {
-	    assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
+	    assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0);
 	  }
 
 	for (i = 0; i < 4; i++)
 	  {
-	    assert(pthread_join(id[i], (void **) &result) == 0);
+	    assert(pthread_join(id[i], &result) == 0);
 #if ! defined (__MINGW32__) || defined (__MSVCRT__)
 	    /* CRTDLL _beginthread doesn't support return value, so
 	       the assertion is guaranteed to fail. */
-	    assert(result == i);
+	    assert((int)(size_t)result == i);
 #endif
 	  }
 
diff --git a/winsup/testsuite/winsup.api/pthread/mutex4.c b/winsup/testsuite/winsup.api/pthread/mutex4.c
index 8a983fee9..f4d31adb5 100644
--- a/winsup/testsuite/winsup.api/pthread/mutex4.c
+++ b/winsup/testsuite/winsup.api/pthread/mutex4.c
@@ -17,7 +17,7 @@ static pthread_mutex_t mutex1;
  
 void * unlocker(void * arg)
 {
-  int expectedResult = (int) arg;
+  int expectedResult = (int)(size_t)arg;
 
   wasHere++;
   assert(pthread_mutex_unlock(&mutex1) == expectedResult);
diff --git a/winsup/testsuite/winsup.api/pthread/priority1.c b/winsup/testsuite/winsup.api/pthread/priority1.c
index a31102895..b740b997f 100644
--- a/winsup/testsuite/winsup.api/pthread/priority1.c
+++ b/winsup/testsuite/winsup.api/pthread/priority1.c
@@ -48,7 +48,7 @@ void * func(void * arg)
 
   assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
   assert(policy == SCHED_OTHER);
-  return (void *) param.sched_priority;
+  return (void *)(size_t)param.sched_priority;
 }
  
 int
@@ -71,7 +71,7 @@ main()
       assert(pthread_attr_setschedparam(&attr, &param) == 0);
       assert(pthread_create(&t, &attr, func, NULL) == 0);
       pthread_join(t, &result);
-      assert((int) result == param.sched_priority);
+      assert((int)(size_t) result == param.sched_priority);
     }
 
   return 0;
diff --git a/winsup/testsuite/winsup.api/pthread/priority2.c b/winsup/testsuite/winsup.api/pthread/priority2.c
index 4dcf3859f..d2d0b0695 100644
--- a/winsup/testsuite/winsup.api/pthread/priority2.c
+++ b/winsup/testsuite/winsup.api/pthread/priority2.c
@@ -52,7 +52,7 @@ void * func(void * arg)
   assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
   assert(pthread_mutex_unlock(&startMx) == 0);
   assert(policy == SCHED_OTHER);
-  return (void *) param.sched_priority;
+  return (void *) (size_t)param.sched_priority;
 }
  
 int
@@ -73,7 +73,7 @@ main()
       assert(pthread_setschedparam(t, SCHED_OTHER, &param) == 0);
       assert(pthread_mutex_unlock(&startMx) == 0);
       pthread_join(t, &result);
-      assert((int) result == param.sched_priority);
+      assert((int)(size_t)result == param.sched_priority);
     }
 
   return 0;
diff --git a/winsup/testsuite/winsup.api/pthread/rwlock6.c b/winsup/testsuite/winsup.api/pthread/rwlock6.c
index d5f2320d0..870b7c264 100644
--- a/winsup/testsuite/winsup.api/pthread/rwlock6.c
+++ b/winsup/testsuite/winsup.api/pthread/rwlock6.c
@@ -25,7 +25,7 @@ void * wrfunc(void * arg)
   ba = bankAccount;
   assert(pthread_rwlock_unlock(&rwlock1) == 0);
 
-  return ((void *) ba);
+  return ((void *)(size_t)ba);
 }
 
 void * rdfunc(void * arg)
@@ -36,7 +36,7 @@ void * rdfunc(void * arg)
   ba = bankAccount;
   assert(pthread_rwlock_unlock(&rwlock1) == 0);
 
-  return ((void *) ba);
+  return ((void *)(size_t)ba);
 }
 
 int
@@ -45,9 +45,9 @@ main()
   pthread_t wrt1;
   pthread_t wrt2;
   pthread_t rdt;
-  int wr1Result = 0;
-  int wr2Result = 0;
-  int rdResult = 0;
+  void* wr1Result = 0;
+  void* wr2Result = 0;
+  void* rdResult = 0;
 
   bankAccount = 0;
 
@@ -57,13 +57,13 @@ main()
   Sleep(500);
   assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0);
 
-  assert(pthread_join(wrt1, (void **) &wr1Result) == 0);
-  assert(pthread_join(rdt, (void **) &rdResult) == 0);
-  assert(pthread_join(wrt2, (void **) &wr2Result) == 0);
+  assert(pthread_join(wrt1, &wr1Result) == 0);
+  assert(pthread_join(rdt, &rdResult) == 0);
+  assert(pthread_join(wrt2, &wr2Result) == 0);
 
-  assert(wr1Result == 10);
-  assert(rdResult == 20);
-  assert(wr2Result == 20);
+  assert((int)(size_t)wr1Result == 10);
+  assert((int)(size_t)rdResult == 20);
+  assert((int)(size_t)wr2Result == 20);
 
   return 0;
 }
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/8] Cygwin: testsuite: Update mutex tests for changed default mutex type
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
                   ` (3 preceding siblings ...)
  2023-01-10 16:37 ` [PATCH 4/8] Cygwin: testsuite: 64-bit fixes in pthread testcases Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 6/8] Cygwin: testsuite: Update pthread tests for default SCHED_FIFO Jon Turney
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Default mutex type is PTHREAD_MUTEX_NORMAL.

Attempting to unlock an unowned mutex of that type is specified as
undefined behaviour, not returning EPERM.

mutex7e verfies that attempting to unlock an unowned mutex of type
PTHREAD_MUTEX_ERRORCHECK returns EPERM.
---
 winsup/testsuite/winsup.api/pthread/mutex5.c  | 2 +-
 winsup/testsuite/winsup.api/pthread/mutex7.c  | 3 +--
 winsup/testsuite/winsup.api/pthread/mutex7d.c | 3 +--
 winsup/testsuite/winsup.api/pthread/mutex7n.c | 1 -
 4 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/winsup/testsuite/winsup.api/pthread/mutex5.c b/winsup/testsuite/winsup.api/pthread/mutex5.c
index 7029da12f..6d24275f1 100644
--- a/winsup/testsuite/winsup.api/pthread/mutex5.c
+++ b/winsup/testsuite/winsup.api/pthread/mutex5.c
@@ -23,7 +23,7 @@ main()
     {
       assert(pthread_mutexattr_init(&mxAttr) == 0);
       assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0);
-      assert(mxType == PTHREAD_MUTEX_ERRORCHECK);
+      assert(mxType == PTHREAD_MUTEX_NORMAL);
     }
 
   return 0;
diff --git a/winsup/testsuite/winsup.api/pthread/mutex7.c b/winsup/testsuite/winsup.api/pthread/mutex7.c
index d2c9f8bee..6acb12317 100644
--- a/winsup/testsuite/winsup.api/pthread/mutex7.c
+++ b/winsup/testsuite/winsup.api/pthread/mutex7.c
@@ -2,7 +2,7 @@
  * mutex7.c
  *
  * Test the default (type not set) mutex type.
- * Should be the same as PTHREAD_MUTEX_ERRORCHECK.
+ * Should be the same as PTHREAD_MUTEX_NORMAL.
  * Thread locks then trylocks mutex (attempted recursive lock).
  * The thread should lock first time and EBUSY second time.
  *
@@ -25,7 +25,6 @@ void * locker(void * arg)
   assert(pthread_mutex_trylock(&mutex) == EBUSY);
   lockCount++;
   assert(pthread_mutex_unlock(&mutex) == 0);
-  assert(pthread_mutex_unlock(&mutex) == EPERM);
 
   return 0;
 }
diff --git a/winsup/testsuite/winsup.api/pthread/mutex7d.c b/winsup/testsuite/winsup.api/pthread/mutex7d.c
index 906d0f043..98b74fc5b 100644
--- a/winsup/testsuite/winsup.api/pthread/mutex7d.c
+++ b/winsup/testsuite/winsup.api/pthread/mutex7d.c
@@ -2,7 +2,7 @@
  * mutex7d.c
  *
  * Test the default (type not set) mutex type.
- * Should be the same as PTHREAD_MUTEX_ERRORCHECK.
+ * Should be the same as PTHREAD_MUTEX_NORMAL.
  * Thread locks then trylocks mutex (attempted recursive lock).
  * The thread should lock first time and EBUSY second time.
  *
@@ -25,7 +25,6 @@ void * locker(void * arg)
   assert(pthread_mutex_trylock(&mutex) == EBUSY);
   lockCount++;
   assert(pthread_mutex_unlock(&mutex) == 0);
-  assert(pthread_mutex_unlock(&mutex) == EPERM);
 
   return 0;
 }
diff --git a/winsup/testsuite/winsup.api/pthread/mutex7n.c b/winsup/testsuite/winsup.api/pthread/mutex7n.c
index e9a36fec0..a04792b61 100644
--- a/winsup/testsuite/winsup.api/pthread/mutex7n.c
+++ b/winsup/testsuite/winsup.api/pthread/mutex7n.c
@@ -29,7 +29,6 @@ void * locker(void * arg)
   assert(pthread_mutex_trylock(&mutex) == EBUSY);
   lockCount++;
   assert(pthread_mutex_unlock(&mutex) == 0);
-  assert(pthread_mutex_unlock(&mutex) == EPERM);
 
   return (void *) 555;
 }
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/8] Cygwin: testsuite: Update pthread tests for default SCHED_FIFO
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
                   ` (4 preceding siblings ...)
  2023-01-10 16:37 ` [PATCH 5/8] Cygwin: testsuite: Update mutex tests for changed default mutex type Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 7/8] Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper Jon Turney
  2023-01-10 16:37 ` [PATCH 8/8] Cygwin: CI: Run cygserver for tests Jon Turney
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Update for default (and only) thread scheduler policy is SCHED_FIFO.
---
 winsup/testsuite/winsup.api/pthread/inherit1.c  | 8 ++++----
 winsup/testsuite/winsup.api/pthread/priority1.c | 6 +++---
 winsup/testsuite/winsup.api/pthread/priority2.c | 8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/winsup/testsuite/winsup.api/pthread/inherit1.c b/winsup/testsuite/winsup.api/pthread/inherit1.c
index 545e4596f..16c3f534b 100644
--- a/winsup/testsuite/winsup.api/pthread/inherit1.c
+++ b/winsup/testsuite/winsup.api/pthread/inherit1.c
@@ -65,8 +65,8 @@ main()
   int policy;
   int inheritsched = -1;
 
-  assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1);
-  assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1);
+  assert((maxPrio = sched_get_priority_max(SCHED_FIFO)) != -1);
+  assert((minPrio = sched_get_priority_min(SCHED_FIFO)) != -1);
 
   assert(pthread_attr_init(&attr) == 0);
   assert(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED) == 0);
@@ -78,9 +78,9 @@ main()
       mainParam.sched_priority = prio;
 
       /* Change the main thread priority */
-      assert(pthread_setschedparam(mainThread, SCHED_OTHER, &mainParam) == 0);
+      assert(pthread_setschedparam(mainThread, SCHED_FIFO, &mainParam) == 0);
       assert(pthread_getschedparam(mainThread, &policy, &mainParam) == 0);
-      assert(policy == SCHED_OTHER);
+      assert(policy == SCHED_FIFO);
       assert(mainParam.sched_priority == prio);
 
       for (param.sched_priority = prio;
diff --git a/winsup/testsuite/winsup.api/pthread/priority1.c b/winsup/testsuite/winsup.api/pthread/priority1.c
index b740b997f..a1e8d051d 100644
--- a/winsup/testsuite/winsup.api/pthread/priority1.c
+++ b/winsup/testsuite/winsup.api/pthread/priority1.c
@@ -47,7 +47,7 @@ void * func(void * arg)
   struct sched_param param;
 
   assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
-  assert(policy == SCHED_OTHER);
+  assert(policy == SCHED_FIFO);
   return (void *)(size_t)param.sched_priority;
 }
  
@@ -58,8 +58,8 @@ main()
   pthread_attr_t attr;
   void * result = NULL;
   struct sched_param param;
-  int maxPrio = sched_get_priority_max(SCHED_OTHER);
-  int minPrio = sched_get_priority_min(SCHED_OTHER);
+  int maxPrio = sched_get_priority_max(SCHED_FIFO);
+  int minPrio = sched_get_priority_min(SCHED_FIFO);
 
   assert(pthread_attr_init(&attr) == 0);
   assert(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0);
diff --git a/winsup/testsuite/winsup.api/pthread/priority2.c b/winsup/testsuite/winsup.api/pthread/priority2.c
index d2d0b0695..0534e7ba1 100644
--- a/winsup/testsuite/winsup.api/pthread/priority2.c
+++ b/winsup/testsuite/winsup.api/pthread/priority2.c
@@ -51,7 +51,7 @@ void * func(void * arg)
   assert(pthread_mutex_lock(&startMx) == 0);
   assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
   assert(pthread_mutex_unlock(&startMx) == 0);
-  assert(policy == SCHED_OTHER);
+  assert(policy == SCHED_FIFO);
   return (void *) (size_t)param.sched_priority;
 }
  
@@ -61,8 +61,8 @@ main()
   pthread_t t;
   void * result = NULL;
   struct sched_param param;
-  int maxPrio = sched_get_priority_max(SCHED_OTHER);
-  int minPrio = sched_get_priority_min(SCHED_OTHER);
+  int maxPrio = sched_get_priority_max(SCHED_FIFO);
+  int minPrio = sched_get_priority_min(SCHED_FIFO);
 
   for (param.sched_priority = minPrio;
        param.sched_priority <= maxPrio;
@@ -70,7 +70,7 @@ main()
     {
       assert(pthread_mutex_lock(&startMx) == 0);
       assert(pthread_create(&t, NULL, func, NULL) == 0);
-      assert(pthread_setschedparam(t, SCHED_OTHER, &param) == 0);
+      assert(pthread_setschedparam(t, SCHED_FIFO, &param) == 0);
       assert(pthread_mutex_unlock(&startMx) == 0);
       pthread_join(t, &result);
       assert((int)(size_t)result == param.sched_priority);
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/8] Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
                   ` (5 preceding siblings ...)
  2023-01-10 16:37 ` [PATCH 6/8] Cygwin: testsuite: Update pthread tests for default SCHED_FIFO Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  2023-01-10 16:37 ` [PATCH 8/8] Cygwin: CI: Run cygserver for tests Jon Turney
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Don't append 'ntsec' to the CYGWIN env var in the cygrun wrapper. It
doesn't have any effect anymore.
---
 winsup/testsuite/cygrun.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/winsup/testsuite/cygrun.c b/winsup/testsuite/cygrun.c
index 65d859d59..e6c4aa705 100644
--- a/winsup/testsuite/cygrun.c
+++ b/winsup/testsuite/cygrun.c
@@ -33,22 +33,6 @@ main (int argc, char **argv)
     SetEnvironmentVariable ("TDIRECTORY", argv[2]);
 
   SetEnvironmentVariable ("CYGWIN_TESTING", "1");
-  if ((p = getenv ("CYGWIN")) == NULL || (strstr (p, "ntsec") == NULL))
-    {
-      char buf[4096];
-      if (!p)
-	{
-	  p = buf;
-	  p[0] = '\0';
-	}
-      else
-	{
-	  strcpy (buf, p);
-	  strcat (buf, " ");
-	}
-      strcat(buf, "ntsec");
-      SetEnvironmentVariable ("CYGWIN", buf);
-    }
 
   memset (&sa, 0, sizeof (sa));
   memset (&pi, 0, sizeof (pi));
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 8/8] Cygwin: CI: Run cygserver for tests
  2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
                   ` (6 preceding siblings ...)
  2023-01-10 16:37 ` [PATCH 7/8] Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper Jon Turney
@ 2023-01-10 16:37 ` Jon Turney
  7 siblings, 0 replies; 9+ messages in thread
From: Jon Turney @ 2023-01-10 16:37 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Note that cygserver must be run using the same cygwin1.DLL as test
programs, as they communicate over a named pipe whose name contains the
'installation key' (which is a hash of the cygwin1.dll's path).

We run cygserver via 'cmd' to avoid the special code which handles a
cygwin parent process starting a cygwin child process, which assumes the
same version of cygwin in both.
---
 .github/workflows/cygwin.yml | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml
index ac167e748..10d0255ef 100644
--- a/.github/workflows/cygwin.yml
+++ b/.github/workflows/cygwin.yml
@@ -52,7 +52,8 @@ jobs:
       fail-fast: false
       matrix:
         include:
-        - pkgarch: x86_64
+        - target: x86_64-pc-cygwin
+          pkgarch: x86_64
     name: Windows native ${{ matrix.pkgarch }}
 
     steps:
@@ -105,6 +106,15 @@ jobs:
         make &&
         make install &&
         (cd */newlib; make info man) &&
-        (cd */newlib; make install-info install-man) &&
-        (cd */winsup; make check || true)
+        (cd */newlib; make install-info install-man)
+      shell: C:\cygwin\bin\bash.exe --noprofile --norc -eo pipefail '{0}'
+
+    # test
+    - name: Test Cygwin
+      run: >-
+        export PATH=/usr/bin:$(cygpath ${SYSTEMROOT})/system32 &&
+        export MAKEFLAGS=-j$(nproc) &&
+        cd build &&
+        (export PATH=${{ matrix.target }}/winsup/testsuite/runtime:${PATH} && cmd /c $(cygpath -wa ${{ matrix.target }}/winsup/cygserver/cygserver) &) &&
+        (cd ${{ matrix.target }}/winsup; make check || true)
       shell: C:\cygwin\bin\bash.exe --noprofile --norc -eo pipefail '{0}'
-- 
2.39.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-01-10 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 16:37 [PATCH 0/8] Further testsuite fixes Jon Turney
2023-01-10 16:37 ` [PATCH 1/8] Cygwin: testsuite: automake doesn't define objdir Jon Turney
2023-01-10 16:37 ` [PATCH 2/8] Cygwin: testsuite: Build testcases using automake Jon Turney
2023-01-10 16:37 ` [PATCH 3/8] Cygwin: testsuite: Fix compilation warnings Jon Turney
2023-01-10 16:37 ` [PATCH 4/8] Cygwin: testsuite: 64-bit fixes in pthread testcases Jon Turney
2023-01-10 16:37 ` [PATCH 5/8] Cygwin: testsuite: Update mutex tests for changed default mutex type Jon Turney
2023-01-10 16:37 ` [PATCH 6/8] Cygwin: testsuite: Update pthread tests for default SCHED_FIFO Jon Turney
2023-01-10 16:37 ` [PATCH 7/8] Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper Jon Turney
2023-01-10 16:37 ` [PATCH 8/8] Cygwin: CI: Run cygserver for tests Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).