1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Add automatized test for sha256

This commit is contained in:
René Kijewski 2014-02-28 18:51:36 +01:00
parent 2562f36f47
commit 07f5ca1b22
2 changed files with 79 additions and 0 deletions

View File

@ -46,6 +46,8 @@ void sha256_calc(const char *str, const char *expected)
int main(void)
{
puts("Start.");
sha256_calc("1234567890_1",
"3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0");
sha256_calc("1234567890_2",
@ -63,5 +65,6 @@ int main(void)
sha256_calc("",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
puts("Done.");
return 0;
}

76
tests/test_sha256/tests/01-test Executable file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env expect
set timeout 5
set pid [spawn make term]
puts "-*- Spawened $pid -*-\n"
set result 0
expect {
"Start." {}
timeout {
set result 1
}
}
while { $result == 0 } {
set result 1
expect {
-regex {Input: +} {
expect {
"\r\n" {}
"\r" {}
"\n" {}
timeout { break }
}
set val_input $expect_out(buffer)
expect {
-regex {Expected: +} {
expect {
"\r\n" {}
"\r" {}
"\n" {}
timeout { break }
}
}
timeout { break }
}
set val_expected $expect_out(buffer)
expect {
-regex {Calculated: +} {
expect {
"\r\n" {}
"\r" {}
"\n" {}
timeout { break }
}
}
timeout { break }
}
set val_calculated $expect_out(buffer)
if { $val_expected == $val_calculated } {
set result 0
} else {
puts "-*- ERROR FOR INPUT <$val_input> -*-"
}
}
"Done." {
set result 0
break
}
timeout { break }
}
}
if { $result == 0 } {
puts "\n-*- Test successful! -*-\n"
} else {
puts "\n-*- TEST HAD ERRORS! -*-\n"
}
spawn kill -9 $pid
wait
close
exit $result