Skip to content

Commit

Permalink
basic compilation test, no testing yet
Browse files Browse the repository at this point in the history
  • Loading branch information
micsthepick committed Feb 28, 2024
1 parent ce7e02c commit a1b64ff
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test JSFX

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v4
name: Check out repository code
with:
# Fetches all submodules recursively
submodules: 'recursive'

- name: Compile EEL2 with NO_GFX
run: |
./compile_wdl.sh
- name: Run Tests
run: |
./test_eel.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,5 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd

*.test.eel2
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "WDL"]
path = WDL
url = https://github.com/justinfrankel/WDL.git
ignore = all
16 changes: 14 additions & 2 deletions REAPERDenoiser
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ out_pin:Denoised Audio 2


@init
///*IFTEST{* // init sliders
slider1=0;
slider2=1;
//*}IFTEST*/ // main test block

// On initialization, initialize all of our variables.

// The FFT size will always be constant.
Expand Down Expand Up @@ -243,13 +248,20 @@ samplesCollected == SIZE/2 ? (
temp = bufferO1R;
bufferO1R = bufferO2R;
bufferO2R = temp;
)
);

/*IFNTEST{*/ // hide serialize
@serialize
// Sliders are serialized automatically, so all we have to serialize is the two
// noise buffers. JSFX's serialization works in a clever way: when reading the
// state of the plugin from a serialized version, these functions copy data into
// noiseBufferL and noiseBufferR. But when writing out the state of the plugin,
// they work the other way, copying data out of noiseBufferL and noiseBufferR.
file_mem(0, noiseBufferL, SIZE);
file_mem(0, noiseBufferR, SIZE);
file_mem(0, noiseBufferR, SIZE);
/*}IFNTSET*/ // hide serialize

///*IFTEST{* // main test block

test_summary();
//*}IFTEST*/ // main test block
1 change: 1 addition & 0 deletions WDL
Submodule WDL added at 805967
5 changes: 5 additions & 0 deletions compile_wdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [ ! -z "$PREFIX" ] && [ "$PREFIX" = "/data/data/com.termux/files/usr" ]; then
# quick hack to enable testing in termux
export CPPFLAGS='-Dpthread_mutexattr_setprotocol\(a,b\)={} -Wno-unused-but-set-variable'
fi
make -C WDL/WDL/eel2 NO_GFX=1
44 changes: 44 additions & 0 deletions test_eel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cat testing_defines.eel2 > REAPERDenoiser.test.eel2
sed -r -e 's/^(desc|slider[0-9]+|(in|out)_pin):.*|^@(init|slider|block|serialize|sample)//' \
-e 's/\/\/DEBUGPRINT/printf/' \
-e 's/\/\/IFTEST|\/\*IFTEST\{\*|\*\}IFTEST\*\///' \
-e 's/\*IFNTEST\*|IFNTEST\{\*|\*\}IFNTEST//' \
REAPERDenoiser >> REAPERDenoiser.test.eel2

# Initialize a flag to indicate stderr output
stderr_output=0

output=$(./WDL/WDL/eel2/loose_eel ./REAPERDenoiser.test.eel2 2>&1)

echo "$output"

# Get the last line of the output
last_line=$(echo "$output" | tail -n 1)

# Check if the last line starts with 'FAILURE'
if echo "$last_line" | grep -q "^FAILURE"; then
echo "Failed Test Cases, will return -1!"
exit -1
fi

##//DEBUGPRINT("HI");
##//IFTEST code_here();
##/*IFTEST{*
## more_code();
##*}IFTEST*/
##/*IFNTEST*/called_when_not_testing();
##/*IFNTEST{*/
## also_called_when_not_testing();
##/*}IFNTEST*/

# will transform to

##printf("HI");
## code_here();
##
## more_code();
##
##//called_when_not_testing();
##/*IFNTEST{*/
## also_called_when_not_testing();
##/*IFNTEST}*/
84 changes: 84 additions & 0 deletions testing_defines.eel2
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

// Helper functions to check for positive infinity, negative infinity, and nan
function is_pos_inf(x) (x == 1/0);
function is_neg_inf(x) (x == -1/0);
function is_nan(x) (x != x;);

function assert_equal_exact(expected, actual, message) global(failed_asserts, successful_asserts) (
is_nan(expected) && is_nan(actual) ? successful_asserts += 1 :
(is_pos_inf(expected) && is_pos_inf(actual)) || (is_neg_inf(expected) && is_neg_inf(actual)) ? successful_asserts += 1 :
expected !== actual ? (
fprintf(3, "\033[0;31mexpected: %g, was: %g. %s\033[0m\n", expected, actual, message);
failed_asserts += 1;
) : successful_asserts += 1;
);

function assert_equal_exact(expected, actual) global() (
assert_equal_exact(expected, actual, "values differ!")
);

function assert_near_equal(expected, tolerance, actual, message) global(failed_asserts, successful_asserts) (
is_nan(expected) || is_nan(actual) || is_nan(tolerance) ? successful_asserts += 1 :
(is_pos_inf(expected) || is_neg_inf(expected)) && (is_pos_inf(actual) || is_neg_inf(actual)) ? successful_asserts += 1 :
abs(expected - actual) > tolerance ? (
fprintf(3, "\033[0;31mexpected: %g (±%g), was: %g. %s\033[0m\n", expected, tolerance, actual, message);
failed_asserts += 1;
) : successful_asserts += 1;
);

function assert_near_equal(expected, tolerance, actual) global() (
assert_near_equal(expected, tolerance, actual, "values are not equal within tolerance!")
);

function assert_true(boolean, message) global(failed_asserts, successful_asserts) (
(!boolean) ? (
fprintf(3, "\033[0;31mexpected: true, was: false. %s\033[0m\n", message);
failed_asserts += 1;
) : successful_asserts += 1;
);

function assert_false(boolean, message) global(failed_asserts, successful_asserts) (
boolean ? (
fprintf(3, "\033[0;31mexpected: false, was: true. %s\033[0m\n", message);
failed_asserts += 1;
) : successful_asserts += 1;
);

function assert_true(boolean) global() (
assert_true(boolean, "");
);

function assert_false(boolean) global() (
assert_false(boolean, "");
);

function test_summary() global(failed_asserts successful_asserts) local(total) (
total = failed_asserts + successful_asserts;
failed_asserts === 0 ? fprintf(3, "\033[0;32mAll %d asserts succeeded.\033[0m\n", total) : (
successful_asserts > 0 ? printf("\033[0;34m%d of %d asserts succeeded.\033[0m\n", successful_asserts, total);
failed_asserts > 0 ? (
printf("\033[0;31m%d of %d asserts failed.\nFAILURE, see above!\033[0m\n", failed_asserts, total);
)
)
);

// drop in for spl(channel)
function spl(channel) (
0 == channel ? spl0 :
1 == channel ? spl1 :
2 == channel ? spl2 :
3 == channel ? spl3 :
4 == channel ? spl4 :
5 == channel ? spl5 :
6 == channel ? spl6 :
7 == channel ? spl7 :
8 == channel ? spl8 :
9 == channel ? spl9 :
10 == channel ? spl10 :
11 == channel ? spl11 :
12 == channel ? spl12 :
13 == channel ? spl13 :
14 == channel ? spl14 :
15 == channel ? spl15 :
0;
);

0 comments on commit a1b64ff

Please sign in to comment.