summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/crypto/bld.sub8
-rw-r--r--lib/crypto/test/md5.myr15
-rw-r--r--lib/crypto/test/sha1.myr15
-rw-r--r--lib/crypto/test/sha256.myr15
-rw-r--r--lib/crypto/test/sha512.myr16
-rw-r--r--lib/crypto/util.myr (renamed from lib/crypto/test/util.myr)2
-rw-r--r--lib/thread/bld.sub4
-rw-r--r--lib/thread/test/atomic.myr4
-rw-r--r--lib/thread/test/mutex.myr4
-rw-r--r--lib/thread/util.myr (renamed from lib/thread/test/util.myr)2
-rw-r--r--mk/c.mk2
11 files changed, 72 insertions, 15 deletions
diff --git a/lib/crypto/bld.sub b/lib/crypto/bld.sub
index ea98d07..34117d1 100644
--- a/lib/crypto/bld.sub
+++ b/lib/crypto/bld.sub
@@ -21,3 +21,11 @@ lib crypto =
lib ../thread:thread
;;
+
+lib testutil =
+ util.myr
+;;
+
+testdeps =
+ testutil
+;;
diff --git a/lib/crypto/test/md5.myr b/lib/crypto/test/md5.myr
index bc0939f..380c531 100644
--- a/lib/crypto/test/md5.myr
+++ b/lib/crypto/test/md5.myr
@@ -1,8 +1,6 @@
use std
use crypto
-use "util"
-
const main = {
hasheq(crypto.md5("")[:], \
"d41d8cd98f00b204e9800998ecf8427e")
@@ -16,3 +14,16 @@ const main = {
"3b0bb4c5ece4a6568caa7266e740a140")
}
+const hasheq = {got, expected
+ var sb, str
+
+ sb = std.mksb()
+ for x : got
+ std.sbfmt(sb, "{p=0,w=2,x}", x)
+ ;;
+ str = std.sbfin(sb)
+ if (!std.sleq(str, expected))
+ std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected)
+ ;;
+ std.slfree(str)
+}
diff --git a/lib/crypto/test/sha1.myr b/lib/crypto/test/sha1.myr
index e750f41..75361f8 100644
--- a/lib/crypto/test/sha1.myr
+++ b/lib/crypto/test/sha1.myr
@@ -1,8 +1,6 @@
use std
use crypto
-use "util"
-
const main = {
hasheq(crypto.sha1("")[:], \
"da39a3ee5e6b4b0d3255bfef60951890d8af0709")
@@ -16,3 +14,16 @@ const main = {
"4eb17e52bb55910b037869438f69d9c87643d75a")
}
+const hasheq = {got, expected
+ var sb, str
+
+ sb = std.mksb()
+ for x : got
+ std.sbfmt(sb, "{p=0,w=2,x}", x)
+ ;;
+ str = std.sbfin(sb)
+ if (!std.sleq(str, expected))
+ std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected)
+ ;;
+ std.slfree(str)
+}
diff --git a/lib/crypto/test/sha256.myr b/lib/crypto/test/sha256.myr
index 958b993..32142d1 100644
--- a/lib/crypto/test/sha256.myr
+++ b/lib/crypto/test/sha256.myr
@@ -1,8 +1,6 @@
use std
use crypto
-use "util"
-
const main = {
hasheq(crypto.sha224("")[:], \
"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f")
@@ -27,3 +25,16 @@ const main = {
"bac8bf0f9794a520a5bf0ec64d3206edd1b9f2ef5ea118c9cad5365d84578de4")
}
+const hasheq = {got, expected
+ var sb, str
+
+ sb = std.mksb()
+ for x : got
+ std.sbfmt(sb, "{p=0,w=2,x}", x)
+ ;;
+ str = std.sbfin(sb)
+ if (!std.sleq(str, expected))
+ std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected)
+ ;;
+ std.slfree(str)
+}
diff --git a/lib/crypto/test/sha512.myr b/lib/crypto/test/sha512.myr
index ddee8e8..cec12f8 100644
--- a/lib/crypto/test/sha512.myr
+++ b/lib/crypto/test/sha512.myr
@@ -1,8 +1,6 @@
use std
use crypto
-use "util"
-
const main = {
hasheq(crypto.sha384("")[:], \
"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b")
@@ -27,3 +25,17 @@ const main = {
"d5c989d2e41299b6bfd57562b4b09cd2efa56f13c8fa109e0ce5ddbd6bfb5b34f8563608d6162104bef750023732581f22704d5df43feecbb05742be1d7c34fa")
}
+
+const hasheq = {got, expected
+ var sb, str
+
+ sb = std.mksb()
+ for x : got
+ std.sbfmt(sb, "{p=0,w=2,x}", x)
+ ;;
+ str = std.sbfin(sb)
+ if (!std.sleq(str, expected))
+ std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected)
+ ;;
+ std.slfree(str)
+}
diff --git a/lib/crypto/test/util.myr b/lib/crypto/util.myr
index e6a3211..2170029 100644
--- a/lib/crypto/test/util.myr
+++ b/lib/crypto/util.myr
@@ -1,6 +1,6 @@
use std
-pkg =
+pkg testutil =
const hasheq : (got : byte[:], expected : byte[:] -> void)
;;
diff --git a/lib/thread/bld.sub b/lib/thread/bld.sub
index 8f892f1..9d69ecd 100644
--- a/lib/thread/bld.sub
+++ b/lib/thread/bld.sub
@@ -45,3 +45,7 @@ lib thread =
lib ../sys:sys
lib ../std:std
;;
+
+lib testutil =
+ util.myr
+;;
diff --git a/lib/thread/test/atomic.myr b/lib/thread/test/atomic.myr
index 3dd3284..4676543 100644
--- a/lib/thread/test/atomic.myr
+++ b/lib/thread/test/atomic.myr
@@ -1,7 +1,7 @@
use std
use thread
-use "util"
+use testutil
const Nherd = 20
@@ -11,7 +11,7 @@ var done : uint32 = 0
const main = {
done = 0
val = 0
- mkherd(Nherd, incvar)
+ testutil.mkherd(Nherd, incvar)
while thread.xget(&done) != Nherd
/* nothing */
;;
diff --git a/lib/thread/test/mutex.myr b/lib/thread/test/mutex.myr
index b366637..f21ce91 100644
--- a/lib/thread/test/mutex.myr
+++ b/lib/thread/test/mutex.myr
@@ -1,7 +1,7 @@
use std
use thread
-use "util"
+use testutil
const Nherd = 20
@@ -14,7 +14,7 @@ const main = {
val = 0
mtx = thread.mkmtx()
- mkherd(Nherd, incvar)
+ testutil.mkherd(Nherd, incvar)
while thread.xget(&done) != Nherd
/* nothing */
;;
diff --git a/lib/thread/test/util.myr b/lib/thread/util.myr
index 610a095..a29d52d 100644
--- a/lib/thread/test/util.myr
+++ b/lib/thread/util.myr
@@ -1,7 +1,7 @@
use std
use thread
-pkg =
+pkg testutil =
const mkherd : (n : uint32, fn : (-> void) ->void)
;;
diff --git a/mk/c.mk b/mk/c.mk
index 25167bc..764846f 100644
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -9,7 +9,7 @@ _LIBINCPATHS=$(addprefix -I, $(dir $(DEPS))) $(_PCHDRS)
_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
# yeah, I should probably remove -Werror, but it's nice for developing alone.
-CFLAGS += -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-char-subscripts -g -O0
+CFLAGS += -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-char-subscripts -g -O3
CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
LIB ?= $(INSTLIB)