run_tests_browser.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. "sha1_test.js",
  15. "sha1_vectors.js",
  16. "hmac_test.js",
  17. "hmac_vectors.js",
  18. "pbkdf2_test.js",
  19. "bn_test.js",
  20. "bn_vectors.js",
  21. "srp_test.js",
  22. "srp_vectors.js"
  23. ], i;
  24. for (i=1; i<testFiles.length; i++) {
  25. testFiles[i] = testPath + testFiles[i];
  26. }
  27. browserUtil.loadScripts(testFiles, function() {
  28. browserUtil.write("begin", coreName);
  29. browserUtil.status("Testing...");
  30. sjcl.test.run([], function () {
  31. browserUtil.status("");
  32. cb && cb();
  33. });
  34. },
  35. function (script, err) {
  36. browserUtil.allPassed = false;
  37. browserUtil.write("begin fail", coreName);
  38. browserUtil.write("fail", "Failed to load "+script+": "+err);
  39. cb();
  40. });
  41. }
  42. function testCores(coreNames, cb) {
  43. browserUtil.cpsMap(function (n,x,y,cb) { testCore(n,cb); }, coreNames, true, function() {
  44. if (browserUtil.allPassed) {
  45. browserUtil.write("pass all", "All tests passed.");
  46. } else {
  47. browserUtil.write("fail all", "All tests complete, but some failed!");
  48. }
  49. cb && cb();
  50. });
  51. }