summaryrefslogtreecommitdiff
path: root/test-sha1.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-06-24 00:59:49 -0700
committerJunio C Hamano <junkio@cox.net>2006-06-24 01:10:40 -0700
commitb65bc21e7d8dc8cafc70dfa6354cb66b8874b2d9 (patch)
treec8b81d0deff46063076468e15ac4964c5ba68969 /test-sha1.c
parent86378b32895ee5d788491b8407608a54e5cf064c (diff)
downloadgit-b65bc21e7d8dc8cafc70dfa6354cb66b8874b2d9.tar.gz
Makefile: add framework to verify and bench sha1 implementations.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'test-sha1.c')
-rw-r--r--test-sha1.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test-sha1.c b/test-sha1.c
new file mode 100644
index 0000000000..2efc315ee3
--- /dev/null
+++ b/test-sha1.c
@@ -0,0 +1,24 @@
+#include "cache.h"
+
+int main(int ac, char **av)
+{
+ SHA_CTX ctx;
+ unsigned char sha1[20];
+
+ SHA1_Init(&ctx);
+
+ while (1) {
+ ssize_t sz;
+ char buffer[8192];
+ sz = xread(0, buffer, sizeof(buffer));
+ if (sz == 0)
+ break;
+ if (sz < 0)
+ die("test-sha1: %s", strerror(errno));
+ SHA1_Update(&ctx, buffer, sz);
+ }
+ SHA1_Final(sha1, &ctx);
+ puts(sha1_to_hex(sha1));
+ exit(0);
+}
+