aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-11-06 16:24:04 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-11-06 16:24:04 +0800
commitda48823cda0905fcf21396c5831b840106cb3a8c (patch)
tree672507ccadbe87f6bd05b41aa197d63f6841a348
parent5f2112059cb6326f03e1ac5585b1df1bb6fdc55f (diff)
downloaddexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.gz
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.bz2
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.lz
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.xz
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.tar.zst
dexon-bls-da48823cda0905fcf21396c5831b840106cb3a8c.zip
update test
-rw-r--r--.travis.yml4
-rw-r--r--Makefile4
-rw-r--r--test/bls_c_test.hpp44
-rw-r--r--test/bls_test.hpp8
4 files changed, 36 insertions, 24 deletions
diff --git a/.travis.yml b/.travis.yml
index 403c433..5f02678 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
-sudo: false
+sudo: true
dist: trusty
language: cpp
compiler:
@@ -12,6 +12,6 @@ install:
- git clone --depth 1 https://github.com/herumi/mcl.git $TRAVIS_BUILD_DIR/../mcl
script:
- make -j3
- - make test DISABLE_THREAD_TEST=1
+ - make test_ci DISABLE_THREAD_TEST=1
- make test_go
- bin/bls_c384_test.exe
diff --git a/Makefile b/Makefile
index 8076813..8b88a72 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,10 @@ SAMPLE_EXE=$(addprefix $(EXE_DIR)/,$(SAMPLE_SRC:.cpp=.exe))
sample: $(SAMPLE_EXE)
TEST_EXE=$(addprefix $(EXE_DIR)/,$(TEST_SRC:.cpp=.exe))
+test_ci: $(TEST_EXE)
+ @sh -ec 'for i in $(TEST_EXE); do echo $$i; env LSAN_OPTIONS=verbosity=1:log_threads=1 $$i; done'
+ $(MAKE) sample_test
+
test: $(TEST_EXE)
@echo test $(TEST_EXE)
@sh -ec 'for i in $(TEST_EXE); do $$i|grep "ctest:name"; done' > result.txt
diff --git a/test/bls_c_test.hpp b/test/bls_c_test.hpp
index 105be86..7864097 100644
--- a/test/bls_c_test.hpp
+++ b/test/bls_c_test.hpp
@@ -301,34 +301,40 @@ void blsBench()
blsGetPublicKey(&pub, &sec);
- CYBOZU_BENCH_C("sign", 1000, blsSign, &sig, &sec, msg, msgSize);
+ CYBOZU_BENCH_C("sign", 10000, blsSign, &sig, &sec, msg, msgSize);
CYBOZU_BENCH_C("verify", 1000, blsVerify, &sig, &pub, msg, msgSize);
}
CYBOZU_TEST_AUTO(all)
{
- const int tbl[] = {
- MCL_BN254,
+ const struct {
+ int curveType;
+ const char *p;
+ const char *r;
+ } tbl[] = {
+ {
+ MCL_BN254,
+ "16798108731015832284940804142231733909759579603404752749028378864165570215949",
+ "16798108731015832284940804142231733909889187121439069848933715426072753864723",
+ },
#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
- MCL_BN381_1,
+ {
+ MCL_BN381_1,
+ "5540996953667913971058039301942914304734176495422447785042938606876043190415948413757785063597439175372845535461389",
+ "5540996953667913971058039301942914304734176495422447785045292539108217242186829586959562222833658991069414454984723",
+ },
#endif
-#if MCLBN_FR_UNIT_SIZE == 6 && MCLBN_FP_UNIT_SIZE == 4
- MCL_BLS12_381,
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4
+ {
+ MCL_BLS12_381,
+ "52435875175126190479447740508185965837690552500527637822603658699938581184513",
+ "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
+ },
#endif
};
- const char *curveOrderTbl[] = {
- "16798108731015832284940804142231733909759579603404752749028378864165570215949",
- "5540996953667913971058039301942914304734176495422447785042938606876043190415948413757785063597439175372845535461389",
- "52435875175126190479447740508185965837690552500527637822603658699938581184513",
- };
- const char *fieldOrderTbl[] = {
- "16798108731015832284940804142231733909889187121439069848933715426072753864723",
- "5540996953667913971058039301942914304734176495422447785045292539108217242186829586959562222833658991069414454984723",
- "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
- };
for (size_t i = 0; i < sizeof(tbl) / sizeof(tbl[0]); i++) {
printf("i=%d\n", (int)i);
- int ret = blsInit(tbl[i], MCLBN_COMPILED_TIME_VAR);
+ int ret = blsInit(tbl[i].curveType, MCLBN_COMPILED_TIME_VAR);
CYBOZU_TEST_EQUAL(ret, 0);
if (ret) {
printf("ERR %d\n", ret);
@@ -336,9 +342,9 @@ CYBOZU_TEST_AUTO(all)
}
bls_use_stackTest();
blsDataTest();
- blsOrderTest(curveOrderTbl[i], fieldOrderTbl[i]);
+ blsOrderTest(tbl[i].p, tbl[i].r);
blsSerializeTest();
- if (tbl[i] == MCL_BLS12_381) blsVerifyOrderTest();
+ if (tbl[i].curveType == MCL_BLS12_381) blsVerifyOrderTest();
blsAddSubTest();
blsBench();
}
diff --git a/test/bls_test.hpp b/test/bls_test.hpp
index 752f6fd..c3f6406 100644
--- a/test/bls_test.hpp
+++ b/test/bls_test.hpp
@@ -104,8 +104,8 @@ void blsTest()
CYBOZU_TEST_ASSERT(sig.verify(pub, m));
CYBOZU_TEST_ASSERT(!sig.verify(pub, m + "a"));
streamTest(sig);
- CYBOZU_BENCH_C("sign", 100, sec.sign, sig, m);
- CYBOZU_BENCH_C("verify", 100, sig.verify, pub, m);
+ CYBOZU_BENCH_C("sign", 10000, sec.sign, sig, m);
+ CYBOZU_BENCH_C("verify", 1000, sig.verify, pub, m);
}
}
@@ -476,8 +476,10 @@ CYBOZU_TEST_AUTO(all)
const char *name;
} tbl[] = {
{ MCL_BN254, "BN254" },
-#if MCLBN_FP_UNIT_SIZE == 6
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 6
{ MCL_BN381_1, "BN381_1" },
+#endif
+#if MCLBN_FP_UNIT_SIZE == 6 && MCLBN_FR_UNIT_SIZE == 4
{ MCL_BLS12_381, "BLS12_381" },
#endif
};