From a29fa27b926813908a791848329a4fea68c28018 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Fri, 3 Jan 2020 22:13:55 +0900 Subject: [PATCH] refactor test --- test/Makefile | 8 +++++++- test/bad_address.cpp | 49 ++++++++++++++------------------------------ test/make_512.cpp | 4 ++-- test/make_nm.cpp | 4 ++-- test/test_address.sh | 1 - test/test_avx.sh | 5 ++--- test/test_avx512.sh | 3 +-- test/test_nm.sh | 5 ++--- 8 files changed, 31 insertions(+), 48 deletions(-) diff --git a/test/Makefile b/test/Makefile index 37a678c..dea57e2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -37,7 +37,7 @@ cvt_test: cvt_test.cpp ../xbyak/xbyak.h cvt_test32: cvt_test.cpp ../xbyak/xbyak.h $(CXX) $(CFLAGS) $< -o $@ -DXBYAK32 -test: normalize_prefix jmp bad_address $(TARGET) +test_nm: normalize_prefix jmp bad_address $(TARGET) $(MAKE) -C ../gen ./test_nm.sh ./test_nm.sh Y @@ -69,6 +69,12 @@ test_avx512: normalize_prefix ifeq ($(BIT),64) ./test_avx512.sh 64 endif + +test: + $(MAKE) test_nm + $(MAKE) test_avx + $(MAKE) test_avx512 + clean: rm -rf *.o $(TARGET) lib_run nm.cpp nm_frame make_512 diff --git a/test/bad_address.cpp b/test/bad_address.cpp index a74dd99..6d74a75 100644 --- a/test/bad_address.cpp +++ b/test/bad_address.cpp @@ -1,47 +1,28 @@ #include - -#define TEST_EXCEPTION(state) \ -{ \ - num++; \ - bool exception = false; \ - try { \ - state; \ - } catch (...) { \ - exception = true; \ - } \ - if (!exception) { \ - printf("exception should arise for %s\n", #state); \ - err++; \ - } \ -} +#include struct Code : Xbyak::CodeGenerator { Code() { - int err = 0; - int num = 0; - TEST_EXCEPTION(mov(eax, ptr [esp + esp])); - TEST_EXCEPTION(mov(eax, ptr [ax])); // not support - TEST_EXCEPTION(mov(eax, ptr [esp * 4])); - TEST_EXCEPTION(mov(eax, ptr [eax * 16])); - TEST_EXCEPTION(mov(eax, ptr [eax + eax + eax])); - TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4])); - TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4])); - TEST_EXCEPTION(mov(eax, ptr [xmm0])); - TEST_EXCEPTION(fld(dword [xmm0])); - TEST_EXCEPTION(vgatherdpd(xmm0, ptr [eax * 2], ymm3)); - TEST_EXCEPTION(vgatherdpd(xmm0, ptr [xmm0 + xmm1], ymm3)); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp + esp]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [ax]), std::exception); // not support + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp * 4]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 16]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax + eax + eax]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0]), std::exception); + CYBOZU_TEST_EXCEPTION(fld(dword [xmm0]), std::exception); + CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [eax * 2], ymm3), std::exception); + CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [xmm0 + xmm1], ymm3), std::exception); #ifdef XBYAK64 - TEST_EXCEPTION(mov(eax, ptr [rax + eax])); - TEST_EXCEPTION(mov(eax, ptr [xmm0 + ymm0])); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [rax + eax]), std::exception); + CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0 + ymm0]), std::exception); #endif - if (!err) { - printf("bad_address test %d ok\n", num); - } } }; -int main() +CYBOZU_TEST_AUTO(exception) { Code c; } diff --git a/test/make_512.cpp b/test/make_512.cpp index ecdaea4..d29adeb 100644 --- a/test/make_512.cpp +++ b/test/make_512.cpp @@ -574,9 +574,9 @@ public: for (size_t k = 0; k < N; k++) { #ifdef XBYAK64 for (int kIdx = 0; kIdx < 8; kIdx++) { + put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx); + put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx); for (int z = 0; z < 2; z++) { - put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx, z == 1); - put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx, z == 1); for (int sae = 0; sae < 5; sae++) { put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae); } diff --git a/test/make_nm.cpp b/test/make_nm.cpp index 54a8014..960cd87 100644 --- a/test/make_nm.cpp +++ b/test/make_nm.cpp @@ -2664,9 +2664,9 @@ public: for (size_t k = 0; k < N; k++) { #ifdef XBYAK64 for (int kIdx = 0; kIdx < 8; kIdx++) { + put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx); + put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx); for (int z = 0; z < 2; z++) { - put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx, z == 1); - put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx, z == 1); for (int sae = 0; sae < 5; sae++) { put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae); } diff --git a/test/test_address.sh b/test/test_address.sh index 8466cc2..d63a4ef 100755 --- a/test/test_address.sh +++ b/test/test_address.sh @@ -20,7 +20,6 @@ echo "compile nm_frame.cpp" g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame ./nm_frame > x.lst diff ok.lst x.lst && echo "ok" -wc x.lst } diff --git a/test/test_avx.sh b/test/test_avx.sh index 0b42eeb..236f7aa 100755 --- a/test/test_avx.sh +++ b/test/test_avx.sh @@ -33,12 +33,11 @@ g++ $CFLAGS make_nm.cpp -o make_nm ./make_nm > a.asm echo "asm" $EXE -f$OPT3 a.asm -l a.lst -awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER > ok.lst +awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER | grep -v "1+1" > ok.lst echo "xbyak" ./make_nm jit > nm.cpp echo "compile nm_frame.cpp" g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame ./nm_frame | $FILTER > x.lst -diff ok.lst x.lst && echo "ok" -exit 0 +diff -B ok.lst x.lst && echo "ok" diff --git a/test/test_avx512.sh b/test/test_avx512.sh index 0a03109..cce5de0 100755 --- a/test/test_avx512.sh +++ b/test/test_avx512.sh @@ -29,5 +29,4 @@ echo "xbyak" echo "compile nm_frame.cpp" g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame -DXBYAK_AVX512 ./nm_frame | $FILTER > x.lst -diff ok.lst x.lst && echo "ok" -exit 0 +diff -B ok.lst x.lst && echo "ok" diff --git a/test/test_nm.sh b/test/test_nm.sh index 6001ace..d3f5b7f 100755 --- a/test/test_nm.sh +++ b/test/test_nm.sh @@ -39,12 +39,11 @@ g++ $CFLAGS make_nm.cpp -o make_nm ./make_nm > a.asm echo "asm" $EXE -f$OPT3 a.asm -l a.lst -awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER > ok.lst +awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER | grep -v "1+1" > ok.lst echo "xbyak" ./make_nm jit > nm.cpp echo "compile nm_frame.cpp" g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame ./nm_frame | $FILTER > x.lst -diff ok.lst x.lst && echo "ok" -exit 0 +diff -B ok.lst x.lst && echo "ok"