diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ae69e70 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: cpp +compiler: + - clang + - gcc +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang +install: + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi +script: ./autobuild diff --git a/autobuild b/autobuild index 35236a0..cc7467b 100755 --- a/autobuild +++ b/autobuild @@ -3,4 +3,5 @@ CXX=g++ command -v clang 2>&1 > /dev/null && CXX=clang++ [ -d m4 ] || mkdir m4 -autoreconf -i && ./configure CXX=$CXX && make && make check +autoreconf -i && ./configure --enable-silent-rules CXX=$CXX \ + && make && make check diff --git a/configure.ac b/configure.ac index 7b2b651..9a1a89f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_PREREQ([2.69]) +AC_PREREQ([2.68]) AC_INIT([libemsha], [1.0.0-RC1], [coder@kyleisom.net], [libemsha], [https://kyleisom.net/projects/libemsha/]) -AM_INIT_AUTOMAKE([1.14 foreign]) +AM_INIT_AUTOMAKE([1.11 foreign]) AC_CONFIG_SRCDIR([src/emsha/sha256.hh]) AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile doc/sphinx/source/conf.py]) diff --git a/src/test_emsha.cc b/src/test_emsha.cc index 2e68063..81cb90e 100644 --- a/src/test_emsha.cc +++ b/src/test_emsha.cc @@ -78,10 +78,13 @@ hash_equal_test(void) } if (!(emsha::hash_equal(a, b))) { + string s; cerr << "FAILED: hash_equal\n"; cerr << "\thash_equal should have succeeded comparing a and b.\n"; - cerr << "\ta <- " << dump_hexstring(a, emsha::SHA256_HASH_SIZE) << std::endl; - cerr << "\tb <- " << dump_hexstring(b, emsha::SHA256_HASH_SIZE) << std::endl; + dump_hexstring(s, a, emsha::SHA256_HASH_SIZE); + cerr << "\ta <- " << s << std::endl; + dump_hexstring(s, b, emsha::SHA256_HASH_SIZE); + cerr << "\tb <- " << s << std::endl; exit(1); } @@ -91,10 +94,13 @@ hash_equal_test(void) } if (emsha::hash_equal(a, b)) { + string s; cerr << "FAILED: hash_equal\n"; cerr << "\thash_equal should not have succeeded comparing a and b.\n"; - cerr << "\ta <- " << dump_hexstring(a, emsha::SHA256_HASH_SIZE) << std::endl; - cerr << "\tb <- " << dump_hexstring(b, emsha::SHA256_HASH_SIZE) << std::endl; + dump_hexstring(s, a, emsha::SHA256_HASH_SIZE); + cerr << "\ta <- " << s << std::endl; + dump_hexstring(s, b, emsha::SHA256_HASH_SIZE); + cerr << "\tb <- " << s << std::endl; exit(1); } diff --git a/src/test_utils.cc b/src/test_utils.cc index e5631bd..8c2b55b 100644 --- a/src/test_utils.cc +++ b/src/test_utils.cc @@ -38,18 +38,18 @@ using std::cerr; using std::endl; -string -dump_hexstring(uint8_t *s, uint32_t sl) +void +dump_hexstring(string& hs, uint8_t *s, uint32_t sl) { uint32_t bl = (2 * sl) + 1; char *buf = new char[bl]; - string hs; + string tmp; memset(buf, 0, bl); emsha::hexstring((uint8_t *)buf, s, sl); - hs = string(buf); + tmp = string(buf); + hs.swap(tmp); delete[] buf; - return hs; } @@ -72,7 +72,7 @@ run_hmac_test(struct hmac_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { res = emsha::EMSHA_TEST_FAILURE; goto exit; @@ -94,7 +94,7 @@ run_hmac_test(struct hmac_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { res = emsha::EMSHA_TEST_FAILURE; goto exit; @@ -111,7 +111,7 @@ run_hmac_test(struct hmac_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { cerr << "(comparing single pass function output)\n"; res = emsha::EMSHA_TEST_FAILURE; @@ -165,7 +165,7 @@ run_hash_test(struct hash_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { res = emsha::EMSHA_TEST_FAILURE; goto exit; @@ -187,7 +187,7 @@ run_hash_test(struct hash_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { res = emsha::EMSHA_TEST_FAILURE; goto exit; @@ -203,7 +203,7 @@ run_hash_test(struct hash_test test, string label) goto exit; } - hs = dump_hexstring(dig, emsha::SHA256_HASH_SIZE); + dump_hexstring(hs, dig, emsha::SHA256_HASH_SIZE); if (hs != test.output) { cerr << "(comparing single pass function output)\n"; res = emsha::EMSHA_TEST_FAILURE; diff --git a/src/test_utils.hh b/src/test_utils.hh index df8bdfc..5719ea6 100644 --- a/src/test_utils.hh +++ b/src/test_utils.hh @@ -59,8 +59,8 @@ struct hmac_test { // General-purpose debuggery. -std::string dump_hexstring(std::uint8_t *, std::uint32_t); -void dump_pair(std::uint8_t *, std::uint8_t *); +void dump_hexstring(std::string&, std::uint8_t *, std::uint32_t); +void dump_pair(std::uint8_t *, std::uint8_t *); // SHA-256 testing functions.