• Dmitry V. Levin's avatar
    selftests: do not macro-expand failed assertion expressions · 3fef5905
    Dmitry V. Levin authored
    [ Upstream commit b708a3cc ]
    
    I've stumbled over the current macro-expand behaviour of the test
    harness:
    
    $ gcc -Wall -xc - <<'__EOF__'
    TEST(macro) {
    	int status = 0;
    	ASSERT_TRUE(WIFSIGNALED(status));
    }
    TEST_HARNESS_MAIN
    __EOF__
    $ ./a.out
    [==========] Running 1 tests from 1 test cases.
    [ RUN      ] global.macro
    <stdin>:4:global.macro:Expected 0 (0) != (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) (0)
    global.macro: Test terminated by assertion
    [     FAIL ] global.macro
    [==========] 0 / 1 tests passed.
    [  FAILED  ]
    
    With this change the output of the same test looks much more
    comprehensible:
    
    [==========] Running 1 tests from 1 test cases.
    [ RUN      ] global.macro
    <stdin>:4:global.macro:Expected 0 (0) != WIFSIGNALED(status) (0)
    global.macro: Test terminated by assertion
    [     FAIL ] global.macro
    [==========] 0 / 1 tests passed.
    [  FAILED  ]
    
    The issue is very similar to the bug fixed in glibc assert(3)
    three years ago:
    https://sourceware.org/bugzilla/show_bug.cgi?id=18604
    
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Will Drewry <wad@chromium.org>
    Cc: linux-kselftest@vger.kernel.org
    Signed-off-by: default avatarDmitry V. Levin <ldv@altlinux.org>
    Acked-by: default avatarKees Cook <keescook@chromium.org>
    Signed-off-by: default avatarShuah Khan <shuah@kernel.org>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    3fef5905
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
bpf Loading commit data...
build Loading commit data...
cgroup Loading commit data...
crypto Loading commit data...
firewire Loading commit data...
gpio Loading commit data...
hv Loading commit data...
iio Loading commit data...
include Loading commit data...
kvm/kvm_stat Loading commit data...
laptop Loading commit data...
leds Loading commit data...
lib Loading commit data...
memory-model Loading commit data...
nfsd Loading commit data...
objtool Loading commit data...
pci Loading commit data...
pcmcia Loading commit data...
perf Loading commit data...
power Loading commit data...
scripts Loading commit data...
spi Loading commit data...
testing Loading commit data...
thermal/tmon Loading commit data...
time Loading commit data...
usb Loading commit data...
virtio Loading commit data...
vm Loading commit data...
wmi Loading commit data...
Makefile Loading commit data...