| 1 | import os |
| 2 | |
| 3 | const sha3_issue_vexe = @VEXE |
| 4 | const sha3_issue_tests_dir = os.dir(@FILE) |
| 5 | const sha3_issue_v3_dir = os.dir(sha3_issue_tests_dir) |
| 6 | const sha3_issue_vlib_dir = os.dir(sha3_issue_v3_dir) |
| 7 | const sha3_issue_v3_src = os.join_path(sha3_issue_v3_dir, 'v3.v') |
| 8 | |
| 9 | // test_sha3_issue_26961_compile validates that v3 can compile the sha3 benchmark |
| 10 | // program from https://github.com/vlang/v/issues/26961 . |
| 11 | fn test_sha3_issue_26961_compile() { |
| 12 | pid := os.getpid() |
| 13 | v3_bin := os.join_path(os.temp_dir(), 'v3_sha3_issue_26961_${pid}') |
| 14 | os.rm(v3_bin) or {} |
| 15 | build := |
| 16 | os.execute('${sha3_issue_vexe} -gc none -path "${sha3_issue_vlib_dir}|@vlib|@vmodules" -o ${v3_bin} ${sha3_issue_v3_src}') |
| 17 | assert build.exit_code == 0, build.output |
| 18 | |
| 19 | src := os.join_path(os.temp_dir(), 'v3_sha3_issue_26961_${pid}.v') |
| 20 | bin := os.join_path(os.temp_dir(), 'v3_sha3_issue_26961_bin_${pid}') |
| 21 | os.write_file(src, 'import crypto.sha3 |
| 22 | import time |
| 23 | |
| 24 | fn main() { |
| 25 | a := []u8{len: 10_000_000} |
| 26 | t1 := time.now() |
| 27 | _ := sha3.sum512(a) |
| 28 | println(time.since(t1)) |
| 29 | } |
| 30 | ') or { |
| 31 | panic(err) |
| 32 | } |
| 33 | os.rm(bin) or {} |
| 34 | os.rm(bin + '.c') or {} |
| 35 | |
| 36 | compile := os.execute('${v3_bin} ${src} -b c -o ${bin}') |
| 37 | assert compile.exit_code == 0, compile.output |
| 38 | assert os.exists(bin), compile.output |
| 39 | } |
| 40 | |