Skip to contentSkip to conversation

tests/migration: Restrict initrd-stress.img to Linux

PATCH In review Philippe Mathieu-Daudé 2 participants 4 messages Jul 10, 2023 – Jul 11, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/migration: Restrict initrd-stress.img to Linux

Trying to build initrd-stress.img on Darwin we get:

  $ ninja tests/migration/initrd-stress.img
  Compiling C object tests/migration/stress.p/stress.c.o
  FAILED: tests/migration/stress.p/stress.c.o
  ../tests/migration/stress.c:24:10: fatal error: 'linux/random.h' file not found
  #include <linux/random.h>
           ^~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

Per the include path, this test is Linux specific. Since this is the single binary built in this directory, restrict the whole meson.build to Linux.

---
 tests/migration/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
tests/migration/meson.build +4 -0
index ac71f13290..56523e0785 100644
@@ -1,3 +1,7 @@
+if targetos != 'linux'
+   subdir_done()
+endif
+
 sysprof = dependency('sysprof-capture-4', required: false)
 glib_static = dependency('glib-2.0', version: glib_req_ver, required: false,
                          method: 'pkg-config', static: true)
Signature · 1 line
2.38.1
#1 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé

Trying to build initrd-stress.img on Darwin we get:

  $ ninja tests/migration/initrd-stress.img
  Compiling C object tests/migration/stress.p/stress.c.o
  FAILED: tests/migration/stress.p/stress.c.o
  ../tests/migration/stress.c:24:10: fatal error: 'linux/random.h' file not found
  #include <linux/random.h>
           ^~~~~~~~~~~~~~~~

I think that's historical accident, as AFAICT, nothing in stress.c needs that include to be present.

Quoted 28 lines

1 error generated.
ninja: build stopped: subcommand failed.

Per the include path, this test is Linux specific. Since this is the single binary built in this directory, restrict the whole meson.build to Linux.

---
 tests/migration/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
tests/migration/meson.build +4 -0
index ac71f13290..56523e0785 100644
@@ -1,3 +1,7 @@
+if targetos != 'linux'
+   subdir_done()
+endif
+
 sysprof = dependency('sysprof-capture-4', required: false)
 glib_static = dependency('glib-2.0', version: glib_req_ver, required: false,
                          method: 'pkg-config', static: true)
Signature · 1 line
2.38.1

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 10 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé

Trying to build initrd-stress.img on Darwin we get:

   $ ninja tests/migration/initrd-stress.img
   Compiling C object tests/migration/stress.p/stress.c.o
   FAILED: tests/migration/stress.p/stress.c.o
   ../tests/migration/stress.c:24:10: fatal error: 'linux/random.h' file not found
   #include <linux/random.h>
            ^~~~~~~~~~~~~~~~
Quoted 2 lines

I think that's historical accident, as AFAICT, nothing in stress.c needs that include to be present.

Removing I get:

../../tests/migration/stress.c:35:12: error: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Werror,-Wdeprecated-declarations]

    return syscall(SYS_gettid);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:746:6: note: 'syscall' has been explicitly marked deprecated here
int      syscall(int, ...);
         ^
../../tests/migration/stress.c:43:16: error: use of undeclared identifier 'RB_POWER_OFF'
        reboot(RB_POWER_OFF);
               ^
../../tests/migration/stress.c:241:39: error: too many arguments to function call, expected 4, have 5
    if (mount("none", dir, fstype, 0, NULL) < 0) {
        ~~~~~                         ^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/stddef.h:89:16: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/mount.h:448:9: note: 'mount' declared here
int     mount(const char *, const char *, int, void *);
        ^

3 errors generated.

#3 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Daniel P. Berrangé
Quoted 8 lines · Philippe Mathieu-Daudé

Trying to build initrd-stress.img on Darwin we get:

   $ ninja tests/migration/initrd-stress.img
   Compiling C object tests/migration/stress.p/stress.c.o
   FAILED: tests/migration/stress.p/stress.c.o
   ../tests/migration/stress.c:24:10: fatal error: 'linux/random.h' file not found
   #include <linux/random.h>
            ^~~~~~~~~~~~~~~~
Quoted 4 lines
Quoted 2 lines

I think that's historical accident, as AFAICT, nothing in stress.c needs that include to be present.

Removing I get:

True, the resulting file is still written to assume Linux userspace.

We can remove the linux/random.h header as it is redundant. Your patch is still needed, just with a more general commit message saying that many requird features are Linux only.

Quoted 27 lines

../../tests/migration/stress.c:35:12: error: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Werror,-Wdeprecated-declarations]

    return syscall(SYS_gettid);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:746:6:
note: 'syscall' has been explicitly marked deprecated here
int      syscall(int, ...);
         ^
../../tests/migration/stress.c:43:16: error: use of undeclared identifier
'RB_POWER_OFF'
        reboot(RB_POWER_OFF);
               ^
../../tests/migration/stress.c:241:39: error: too many arguments to function
call, expected 4, have 5
    if (mount("none", dir, fstype, 0, NULL) < 0) {
        ~~~~~                         ^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/stddef.h:89:16:
note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/mount.h:448:9:
note: 'mount' declared here
int     mount(const char *, const char *, int, void *);
        ^
Quoted 2 lines

3 errors generated.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|