run_tests_browser.js 1.2 KB

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