Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wireguard: selftests: set fake real time in init

Not all platforms have an RTC, and rather than trying to force one into
each, it's much easier to just set a fixed time. This is necessary
because WireGuard's latest handshakes parameter is returned in wallclock
time, and if the system time isn't set, and the system is really fast,
then this returns 0, which trips the test.

Turning this on requires setting CONFIG_COMPAT_32BIT_TIME=y, as musl
doesn't support settimeofday without it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jason A. Donenfeld and committed by
Jakub Kicinski
829be057 faa4e04e

+18
+1
tools/testing/selftests/wireguard/qemu/arch/arm.config
··· 7 7 CONFIG_VIRTIO_MENU=y 8 8 CONFIG_VIRTIO_MMIO=y 9 9 CONFIG_VIRTIO_CONSOLE=y 10 + CONFIG_COMPAT_32BIT_TIME=y 10 11 CONFIG_CMDLINE_BOOL=y 11 12 CONFIG_CMDLINE="console=ttyAMA0 wg.success=vport0p1 panic_on_warn=1" 12 13 CONFIG_FRAME_WARN=1024
+1
tools/testing/selftests/wireguard/qemu/arch/armeb.config
··· 7 7 CONFIG_VIRTIO_MENU=y 8 8 CONFIG_VIRTIO_MMIO=y 9 9 CONFIG_VIRTIO_CONSOLE=y 10 + CONFIG_COMPAT_32BIT_TIME=y 10 11 CONFIG_CMDLINE_BOOL=y 11 12 CONFIG_CMDLINE="console=ttyAMA0 wg.success=vport0p1 panic_on_warn=1" 12 13 CONFIG_CPU_BIG_ENDIAN=y
+1
tools/testing/selftests/wireguard/qemu/arch/i686.config
··· 1 1 CONFIG_ACPI=y 2 2 CONFIG_SERIAL_8250=y 3 3 CONFIG_SERIAL_8250_CONSOLE=y 4 + CONFIG_COMPAT_32BIT_TIME=y 4 5 CONFIG_CMDLINE_BOOL=y 5 6 CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1 panic_on_warn=1" 6 7 CONFIG_FRAME_WARN=1024
+1
tools/testing/selftests/wireguard/qemu/arch/m68k.config
··· 5 5 CONFIG_SERIAL_PMACZILOG=y 6 6 CONFIG_SERIAL_PMACZILOG_TTYS=y 7 7 CONFIG_SERIAL_PMACZILOG_CONSOLE=y 8 + CONFIG_COMPAT_32BIT_TIME=y 8 9 CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1 panic_on_warn=1" 9 10 CONFIG_FRAME_WARN=1024
+1
tools/testing/selftests/wireguard/qemu/arch/mips.config
··· 6 6 CONFIG_POWER_RESET_SYSCON=y 7 7 CONFIG_SERIAL_8250=y 8 8 CONFIG_SERIAL_8250_CONSOLE=y 9 + CONFIG_COMPAT_32BIT_TIME=y 9 10 CONFIG_CMDLINE_BOOL=y 10 11 CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1 panic_on_warn=1" 11 12 CONFIG_FRAME_WARN=1024
+1
tools/testing/selftests/wireguard/qemu/arch/mipsel.config
··· 7 7 CONFIG_POWER_RESET_SYSCON=y 8 8 CONFIG_SERIAL_8250=y 9 9 CONFIG_SERIAL_8250_CONSOLE=y 10 + CONFIG_COMPAT_32BIT_TIME=y 10 11 CONFIG_CMDLINE_BOOL=y 11 12 CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1 panic_on_warn=1" 12 13 CONFIG_FRAME_WARN=1024
+1
tools/testing/selftests/wireguard/qemu/arch/powerpc.config
··· 4 4 CONFIG_PHYS_64BIT=y 5 5 CONFIG_SERIAL_8250=y 6 6 CONFIG_SERIAL_8250_CONSOLE=y 7 + CONFIG_COMPAT_32BIT_TIME=y 7 8 CONFIG_MATH_EMULATION=y 8 9 CONFIG_CMDLINE_BOOL=y 9 10 CONFIG_CMDLINE="console=ttyS0 wg.success=ttyS1 panic_on_warn=1"
+11
tools/testing/selftests/wireguard/qemu/init.c
··· 11 11 #include <stdlib.h> 12 12 #include <stdbool.h> 13 13 #include <fcntl.h> 14 + #include <time.h> 14 15 #include <sys/wait.h> 15 16 #include <sys/mount.h> 16 17 #include <sys/stat.h> ··· 69 68 if (ioctl(fd, RNDADDTOENTCNT, &bits) < 0) 70 69 panic("ioctl(RNDADDTOENTCNT)"); 71 70 close(fd); 71 + } 72 + 73 + static void set_time(void) 74 + { 75 + if (time(NULL)) 76 + return; 77 + pretty_message("[+] Setting fake time..."); 78 + if (stime(&(time_t){1433512680}) < 0) 79 + panic("settimeofday()"); 72 80 } 73 81 74 82 static void mount_filesystems(void) ··· 269 259 print_banner(); 270 260 mount_filesystems(); 271 261 seed_rng(); 262 + set_time(); 272 263 kmod_selftests(); 273 264 enable_logging(); 274 265 clear_leaks();