Skip to content

Commit 3482cd0

Browse files
authored
Run fewer basic math tests, and move a test to other (#20853)
test_aligned_alloc was moved to other as it tests a libc method (aligned_alloc) which does not depend on the emcc optimization level we run the test with. test_unaligned was not being run as it is irrelevant for the wasm backend, so remove it.
1 parent 165e568 commit 3482cd0

File tree

2 files changed

+10
-71
lines changed

2 files changed

+10
-71
lines changed

test/test_core.py

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -597,71 +597,7 @@ def test_cube2hash(self):
597597
('64bitisslow', '64D8470573635EC354FEE7B7F87C566FCAF1EFB491041670')]:
598598
self.do_run('src.js', 'hash value: ' + output, args=[text], no_build=True)
599599

600-
def test_unaligned(self):
601-
self.skipTest('LLVM marks the reads of s as fully aligned, making this test invalid')
602-
src = r'''
603-
#include <stdio.h>
604-
605-
struct S {
606-
double x;
607-
int y;
608-
};
609-
610-
int main() {
611-
// the 64-bit value here will not be 8-byte aligned
612-
S s0[3] = { {0x12a751f430142, 22}, {0x17a5c85bad144, 98}, {1, 1}};
613-
char buffer[10*sizeof(S)];
614-
int b = int(buffer);
615-
S *s = (S*)(b + 4-b%8);
616-
s[0] = s0[0];
617-
s[1] = s0[1];
618-
s[2] = s0[2];
619-
620-
printf("*%d : %d : %d\n", sizeof(S), ((unsigned long)&s[0]) % 8 != ((unsigned long)&s[1]) % 8,
621-
((unsigned long)&s[1]) - ((unsigned long)&s[0]));
622-
s[0].x++;
623-
s[0].y++;
624-
s[1].x++;
625-
s[1].y++;
626-
printf("%.1f,%d,%.1f,%d\n", s[0].x, s[0].y, s[1].x, s[1].y);
627-
return 0;
628-
}
629-
'''
630-
631-
# TODO: A version of this with int64s as well
632-
633-
self.do_run(src, '*12 : 1 : 12\n328157500735811.0,23,416012775903557.0,99\n')
634-
635-
return # TODO: continue to the next part here
636-
637-
# Test for undefined behavior in C. This is not legitimate code, but does exist
638-
639-
src = r'''
640-
#include <stdio.h>
641-
642-
int main()
643-
{
644-
int x[10];
645-
char *p = (char*)&x[0];
646-
p++;
647-
short *q = (short*)p;
648-
*q = 300;
649-
printf("*%d:%ld*\n", *q, ((long)q)%2);
650-
int *r = (int*)p;
651-
*r = 515559;
652-
printf("*%d*\n", *r);
653-
long long *t = (long long*)p;
654-
*t = 42949672960;
655-
printf("*%lld*\n", *t);
656-
return 0;
657-
}
658-
'''
659-
660-
try:
661-
self.do_run(src, '*300:1*\n*515559*\n*42949672960*\n')
662-
except Exception as e:
663-
assert 'must be aligned' in str(e), e # expected to fail without emulation
664-
600+
@only_wasm2js('tests 64-bit alignment of structs')
665601
def test_align64(self):
666602
src = r'''
667603
#include <stdio.h>
@@ -710,12 +646,7 @@ def test_align64(self):
710646
0.00,10,123.46,0.00 : 0.00,10,123.46,0.00
711647
''')
712648

713-
@no_asan('asan errors on corner cases we check')
714-
@no_lsan('lsan errors on corner cases we check')
715-
def test_aligned_alloc(self):
716-
self.do_runf('test_aligned_alloc.c', '',
717-
emcc_args=['-Wno-non-power-of-two-alignment'])
718-
649+
@only_wasm2js('tests signed vs unsigned values')
719650
def test_unsigned(self):
720651
src = '''
721652
#include <stdio.h>
@@ -801,22 +732,26 @@ def test_unsigned(self):
801732
'''
802733
self.do_run(src, '*255*\n*65535*\n*-1*\n*-1*\n*-1*')
803734

735+
@only_wasm2js('tests 1-bit fields')
804736
def test_bitfields(self):
805737
self.do_core_test('test_bitfields.c')
806738

807739
def test_floatvars(self):
808740
self.do_core_test('test_floatvars.cpp')
809741

742+
@only_wasm2js('tests pointer casts')
810743
def test_closebitcasts(self):
811744
self.do_core_test('closebitcasts.c')
812745

813746
def test_fast_math(self):
814747
self.emcc_args += ['-ffast-math']
815748
self.do_core_test('test_fast_math.c', args=['5', '6', '8'])
816749

750+
@only_wasm2js('tests division by zero')
817751
def test_zerodiv(self):
818752
self.do_core_test('test_zerodiv.c')
819753

754+
@only_wasm2js('tests multiplication by zero')
820755
def test_zero_multiplication(self):
821756
# needs to flush stdio streams
822757
self.set_setting('EXIT_RUNTIME')

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14244,3 +14244,7 @@ def test_sysroot_includes_first(self):
1424414244
def test_force_filesystem_error(self):
1424514245
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sFILESYSTEM=0', '-sFORCE_FILESYSTEM'])
1424614246
self.assertContained('emcc: error: `-sFORCE_FILESYSTEM` cannot be used with `-sFILESYSTEM=0`', err)
14247+
14248+
def test_aligned_alloc(self):
14249+
self.do_runf('test_aligned_alloc.c', '',
14250+
emcc_args=['-Wno-non-power-of-two-alignment'])

0 commit comments

Comments
 (0)