run_tests_browser.js 1.3 KB

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