msys2-runtime icon indicating copy to clipboard operation
msys2-runtime copied to clipboard

Run unit tests in CI

Open lazka opened this issue 3 years ago • 4 comments

It would be nice if we would run cygwin tests in CI, so we can sleep better.

Running unit tests in 3.4 is currently broken in general (this should fix the basics: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=4e7817498efc8ad74b7266d034abc5c4e45de44e)

There have been a bunch of fixes in cygwin master to improve the tests, so we could either backport them, or wait for 3.5.

lazka avatar Jan 15 '23 10:01 lazka

I agree it would be nice. So I gave it a try, and I need these changes thus far:

diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index 2289556682..472263cd87 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -318,7 +318,7 @@ check_PROGRAMS = \
 # 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
+LDADD_FOR_TESTDLL = $(builddir)/../cygwin/libmsys-2.0.a -lgcc -lkernel32 -luser32
 
 # flags for test executables
 AM_CPPFLAGS = -I$(srcdir)/libltp/include
diff --git a/winsup/testsuite/cygrun.sh b/winsup/testsuite/cygrun.sh
index bf1d5cc6b5..29d107b22f 100755
--- a/winsup/testsuite/cygrun.sh
+++ b/winsup/testsuite/cygrun.sh
@@ -11,7 +11,7 @@ export PATH="$runtime_root:${PATH}"
 if [ "$1" = "./mingw/cygload" ]
 then
     windows_runtime_root=$(cygpath -m $runtime_root)
-    $cygrun "$exe -v -cygwin $windows_runtime_root/cygwin1.dll"
+    MSYS_NO_PATHCONV=1 $cygrun "$exe -v -cygwin $windows_runtime_root/msys-2.0.dll"
 else
-    cygdrop $cygrun $exe
+    $cygrun $exe
 fi

However, even with this, most tests don't seem to pass (this is running make -j15 -C x86_64-pc-msys/winsup/testsuite/ check-TESTS AM_COLOR_TESTS=always):

Image

It seems mingw/cygrun is confused by MSYS2's path conversion:

$ cat x86_64-pc-msys/winsup/testsuite/mingw/cygload.log
+ cygpath -m /usr/src/MSYS2-packages/msys2-runtime/src/msys2-playground/x86_64-pc-msys/winsup/testsuite/testinst/bin
+ windows_runtime_root=C:/git-sdk-64/usr/src/MSYS2-packages/msys2-runtime/src/msys2-playground/x86_64-pc-msys/winsup/testsuite/testinst/bin
+ MSYS_NO_PATHCONV=1 ./mingw/cygrun ./mingw/cygload -v -cygwin C:/git-sdk-64/usr/src/MSYS2-packages/msys2-runtime/src/msys2-playground/x86_64-pc-msys/winsup/testsuite/testinst/bin/msys-2.0.dll
Connecting to cygwin...
Warning!  Stack base is 0xbba6c00000.  padding ends at 0xbba6bffa68.  Delta is 1432.  Stack variables could be overwritten!
Loading C;C:\git-sdk-64\git-sdk-64\usr\src\MSYS2-packages\msys2-runtime\src\msys2-playground\x86_64-pc-msys\winsup\testsuite\testinst\bin\msys-2.0.dll...
LoadLibrary(C;C:\git-sdk-64\git-sdk-64\usr\src\MSYS2-packages\msys2-runtime\src\msys2-playground\x86_64-pc-msys\winsup\testsuite\testinst\bin\msys-2.0.dll):  The specified module could not be found. (126)
FAIL mingw/cygload (exit status: 2)

I guess some tests would require running in a Bash that uses the just-compiled msys-2.0.dll, e.g. winsup.api/shmtest:

$ cat x86_64-pc-msys/winsup/testsuite/winsup.api/shmtest.log
FAIL winsup.api/shmtest.exe (exit status: 11)

$ x86_64-pc-msys/winsup/testsuite/winsup.api/shmtest.exe
shmtest     1  PASS  :  ftok("/") returns valid value
shmtest     2  FAIL  :  sender calls shmget
shmtest     3  FAIL  :  shmctl IPC_STAT
PERM: uid 270735424, gid 2, cuid 270970654, cgid 2, mode 0140
segsz 270960416, lpid 2, cpid -13008, nattch 7
atime: Thu Jan  1 01:00:00 1970
dtime: Sat Oct  5 09:52:02 2250
ctime: Thu Jan  1 01:00:00 1970
shmtest     4  FAIL  :  uid matches
shmtest     5  FAIL  :  gid matches
shmtest     6  FAIL  :  mode matches
shmtest     7  FAIL  :  shmctl IPC_SET
shmtest     8  FAIL  :  shmctl IPC_STAT
shmtest     9  FAIL  :  IPC_SET of mode holds
PERM: uid 0, gid 0, cuid 0, cgid 0, mode 00
segsz 0, lpid 0, cpid 0, nattch 0
atime: Thu Jan  1 01:00:00 1970
dtime: Thu Jan  1 01:00:00 1970
ctime: Thu Jan  1 01:00:00 1970
shmtest    10  FAIL  :  uid matches
shmtest    11  FAIL  :  gid matches
shmtest    12  FAIL  :  mode matches
shmtest    13  FAIL  :  sender: shmat
Segmentation fault (core dumped)

$ cp -i ./x86_64-pc-msys/winsup/testsuite/testinst/bin/msys-2.0.dll x86_64-pc-msys/winsup/testsuite/winsup.api/

$ x86_64-pc-msys/winsup/testsuite/winsup.api/shmtest.exe
      0 [main] shmtest (26836) shared_info::initialize: size of shared memory region changed from 58296 to 57272

dscho avatar Feb 27 '24 19:02 dscho

  • cygdrop $cygrun $exe
  • $cygrun $exe

FWIW it looks as if the cygdrop executable's source code is here.

dscho avatar Feb 27 '24 20:02 dscho

We have it packaged too: https://packages.msys2.org/package/cygutils

lazka avatar Feb 28 '24 06:02 lazka

Nice to see that I wasn't totally wasting my time trying to get this back into some sore of reasonable shape. Disappoiningly many failures though.

I suspect that the failure of shmtest is due to the fact that it expects the just built cygserver to be running (this is should probably be better integrated rather than being done explicitly before running tests in CI : https://github.com/cygwin/cygwin/blob/abb532a87ff6ed37f6ee2c8a58c65178a15aa345/.github/workflows/cygwin.yml#L165)

With cygdrop, again this is an instance of me being lazy, and perhaps it would be better if the cygrun wrapper learnt to drop priviliges like that (and then maybe there are some tests where it makes sense to run them with and without adminstrator privs)

jon-turney avatar Mar 03 '24 13:03 jon-turney