Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/gen When running the tests under "qemu -accel...



details:   https://anonhg.NetBSD.org/src/rev/96386d8a7123
branches:  trunk
changeset: 1027669:96386d8a7123
user:      gson <gson%NetBSD.org@localhost>
date:      Wed Dec 15 09:19:28 2021 +0000

description:
When running the tests under "qemu -accel kvm" on a Linux host,
isQEMU_TCG() should return false.  Fixes multiple test cases that were
failing with "Test case was expecting a failure but none were raised"
on that platform.

diffstat:

 tests/lib/libc/gen/isqemu.h |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 9317c4619543 -r 96386d8a7123 tests/lib/libc/gen/isqemu.h
--- a/tests/lib/libc/gen/isqemu.h       Wed Dec 15 08:42:48 2021 +0000
+++ b/tests/lib/libc/gen/isqemu.h       Wed Dec 15 09:19:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isqemu.h,v 1.5 2020/08/23 11:00:18 gson Exp $  */
+/*     $NetBSD: isqemu.h,v 1.6 2021/12/15 09:19:28 gson Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -72,10 +72,18 @@
                        return false;
                err(EXIT_FAILURE, "sysctl");
        }
-       return strstr(name, "QEMU") != NULL;
-#else
+       if (strstr(name, "QEMU") == NULL)
+               return false;
+       if (sysctlbyname("machdep.hypervisor", name, &len, NULL, 0) == -1) {
+               if (errno == ENOENT)
+                       return true;
+               err(EXIT_FAILURE, "sysctl");
+       }
+       if (strcmp(name, "KVM") == 0)
+               return false;
+       return true;
+#endif
        return false;
-#endif
 }
 
 #ifdef TEST



Home | Main Index | Thread Index | Old Index