update test

dev
MITSUNARI Shigeo 6 years ago
parent 5f2112059c
commit da48823cda
  1. 4
      .travis.yml
  2. 4
      Makefile
  3. 44
      test/bls_c_test.hpp
  4. 8
      test/bls_test.hpp

@ -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

@ -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

@ -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();
}

@ -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
};

Loading…
Cancel
Save