run_tests_browser.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function testCore(coreName, cb) {
  2. var corePath = "../", testPath = "../test/", testFiles = [
  3. corePath + coreName,
  4. "test.js",
  5. "aes_test.js",
  6. "aes_vectors.js",
  7. "ccm_test.js",
  8. "ccm_vectors.js",
  9. "ocb2_test.js",
  10. "ocb2_vectors.js",
  11. "sha256_test.js",
  12. "sha256_vectors.js",
  13. "sha256_test_brute_force.js",
  14. "hmac_test.js",
  15. "hmac_vectors.js",
  16. "pbkdf2_test.js",
  17. "ecdh_test.js",
  18. "ecdsa_test.js"
  19. ], i;
  20. for (i=1; i<testFiles.length; i++) {
  21. testFiles[i] = testPath + testFiles[i];
  22. }
  23. browserUtil.loadScripts(testFiles, function() {
  24. browserUtil.write("begin", coreName);
  25. browserUtil.status("Testing...");
  26. sjcl.test.run([], function () {
  27. browserUtil.status("");
  28. cb && cb();
  29. });
  30. },
  31. function (script, err) {
  32. browserUtil.allPassed = false;
  33. browserUtil.write("begin fail", coreName);
  34. browserUtil.write("fail", "Failed to load "+script+": "+err);
  35. cb();
  36. });
  37. }
  38. function testCores(coreNames, cb) {
  39. browserUtil.cpsMap(function (n,x,y,cb) { testCore(n,cb); }, coreNames, true, function() {
  40. if (browserUtil.allPassed) {
  41. browserUtil.write("pass all", "All tests passed.");
  42. } else {
  43. browserUtil.write("fail all", "All tests complete, but some failed!");
  44. }
  45. cb && cb();
  46. });
  47. }