test(frontend): test TFHE-rs example

This commit is contained in:
youben11
2024-09-19 15:56:11 +01:00
committed by Quentin Bourgerie
parent 061715cfe4
commit 1ecaa5b033
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#!/bin/sh
# This file tests that the example is working
shell_blocks=$(sed -n '/^```sh/,/^```/ p' < README.md | sed '/^```sh/d' | sed '/^```/d')
set -e
output=$(eval "$shell_blocks" 2>&1) || echo "$output"
result=$(echo "$output" | grep "result: " | sed 's/result: //g')
expected="31"
if [ $result -eq $expected ]
then
exit 0
else
echo "expected result to be $expected, but result was $result"
exit 1
fi

View File

@@ -2,6 +2,7 @@
Tests of the examples.
"""
import os
from typing import Optional
import numpy as np
@@ -404,3 +405,13 @@ Actual Output
{actual_output}
"""
def test_tfhers_example():
path_to_test_script = tfhers_utils = (
f"{os.path.dirname(os.path.abspath(__file__))}/../../examples/tfhers/"
)
test_script_filename = "test.sh"
assert (
os.system(f"cd {path_to_test_script} && sh {test_script_filename}") == 0
), "test script failed"