From 3c53ca6272ead7592d434a052d31b81f662757d6 Mon Sep 17 00:00:00 2001 From: Mooneer Salem Date: Fri, 19 Aug 2022 23:00:37 -0700 Subject: [PATCH] Revert "Resolve path issues preventing ctest run." This reverts commit a5b1996142fe93f5456c38f104945bfa20305a9f. --- CMakeLists.txt | 11 ++---- unittest/test_core_nn.sh | 68 +++++++++++++++++++++++++++++++++++++ unittest/test_core_nn.sh.in | 68 ------------------------------------- 3 files changed, 71 insertions(+), 76 deletions(-) create mode 100755 unittest/test_core_nn.sh delete mode 100755 unittest/test_core_nn.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a53e2..ba2339b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,21 +179,16 @@ include(CTest) enable_testing() add_test(NAME core_synthesis_default - COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/unittest; SYNTH=1 ./test_core_nn.sh") + COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH=1 ./test_core_nn.sh") add_test(NAME core_synthesis_load_20h - COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/unittest; SYNTH_20h=1 ./test_core_nn.sh") + COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH_20h=1 ./test_core_nn.sh") add_test(NAME core_synthesis_mag - COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/unittest; SYNTH_mag=1 ./test_core_nn.sh") + COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH_mag=1 ./test_core_nn.sh") add_test(NAME nnet2f32 COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}; ./src/nnet2f32 t.f32") add_test(NAME SIMD_functions COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}; ./src/test_vec") -# -# generate ctest script -# -configure_file(unittest/test_core_nn.sh.in unittest/test_core_nn.sh @ONLY) - # Packaging set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio") set(CPACK_PACKAGE_VENDOR "CMake") diff --git a/unittest/test_core_nn.sh b/unittest/test_core_nn.sh new file mode 100755 index 0000000..cd955c7 --- /dev/null +++ b/unittest/test_core_nn.sh @@ -0,0 +1,68 @@ +#!/bin/bash -x +# test_core_nn.sh +# + +# Some tests for core NN, e.g. generation of test data using +# dump_data, and unquantised synthesis using and test_lpcnet. Used to +# ensure no existing features are broken during experimentation and +# development. + +# test generation of training data (doesn't really test training as that takes hours) +# TODO: This test not working yet +if [ ! -z $TRAIN_TEST ]; then + TRAIN_SRC=all_speech + TRAIN_OUT_PCM=$(mktemp).pcm + TRAIN_OUT_F32=$(mktemp).f32 + TRAIN_TARG_PCM=all_speech.pcm + TRAIN_TARG_F32=all_speech.f32 + ../build_linux/src/dump_data --train --c2pitch -z 0 -n 1E6 ~/Downloads/$TRAIN_SRC.sw $TRAIN_OUT_F32 $TRAIN_OUT_PCM + diff $TRAIN_OUT_F32 $TRAIN_TARG_F32 || { echo "ERROR in train .f32 output! Exiting..."; exit 1; } + echo "train .f32 OK" + diff $TRAIN_OUT_PCM $TRAIN_TARG_PCM || { echo "ERROR in train .pcm output! Exiting..."; exit 1; } + echo "train .pcm OK" +fi + +# Basic synthesis with compiled-in in network + +if [ ! -z $SYNTH ]; then + ../build_linux/src/dump_data --test --c2pitch ../wav/birch.wav birch.f32 + diff birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } + echo "synth .f32 OK" + ../build_linux/src/test_lpcnet -l birch_states.f32 birch.f32 birch_out.raw + octave -p ../src --no-gui <<< "ret=compare_states('birch_states_targ.f32', 'birch_states.f32'); quit(ret)" + if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi + echo "synth states Octave OK" + diff birch_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; } + echo "synth states OK" + diff birch_out_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } + echo "synth .raw OK" +fi + +# Synthesis with the 20h network, loaded up at run time + +if [ ! -z $SYNTH_20h ]; then + ../build_linux/src/dump_data --test --c2pitch ../wav/birch.wav birch.f32 + diff birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } + echo "synth .f32 OK" + ../build_linux/src/test_lpcnet -n lpcnet_20h.f32 -l birch_states.f32 birch.f32 birch_out.raw + octave -p ../src --no-gui <<< "ret=compare_states('birch_20h_states_targ.f32', 'birch_states.f32'); quit(ret)" + if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi + echo "synth states Octave OK" + diff birch_20h_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; } + echo "synth states OK" + diff birch_20h_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } + echo "synth .raw OK" +fi + +# Testing log mag operation, using 190804a network. Not checking states in this test + +if [ ! -z $SYNTH_mag ]; then + ../build_linux/src/dump_data --mag --test --c2pitch ../wav/c01_01.wav c01_01.f32 + diff c01_01_mag.f32 c01_01.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } + echo "mag .f32 OK" + ../build_linux/src/test_lpcnet --mag 1 -n lpcnet_190804a.f32 c01_01.f32 c01_01_out.raw + diff c01_01_190804a_targ.raw c01_01_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } + echo "mag .raw OK" +fi + +echo "all tests PASSED" diff --git a/unittest/test_core_nn.sh.in b/unittest/test_core_nn.sh.in deleted file mode 100755 index a117058..0000000 --- a/unittest/test_core_nn.sh.in +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -x -# test_core_nn.sh -# - -# Some tests for core NN, e.g. generation of test data using -# dump_data, and unquantised synthesis using and test_lpcnet. Used to -# ensure no existing features are broken during experimentation and -# development. - -# test generation of training data (doesn't really test training as that takes hours) -# TODO: This test not working yet -if [ ! -z $TRAIN_TEST ]; then - TRAIN_SRC=all_speech - TRAIN_OUT_PCM=$(mktemp).pcm - TRAIN_OUT_F32=$(mktemp).f32 - TRAIN_TARG_PCM=all_speech.pcm - TRAIN_TARG_F32=all_speech.f32 - @CMAKE_CURRENT_BINARY_DIR@/src/dump_data --train --c2pitch -z 0 -n 1E6 ~/Downloads/$TRAIN_SRC.sw $TRAIN_OUT_F32 $TRAIN_OUT_PCM - diff $TRAIN_OUT_F32 $TRAIN_TARG_F32 || { echo "ERROR in train .f32 output! Exiting..."; exit 1; } - echo "train .f32 OK" - diff $TRAIN_OUT_PCM $TRAIN_TARG_PCM || { echo "ERROR in train .pcm output! Exiting..."; exit 1; } - echo "train .pcm OK" -fi - -# Basic synthesis with compiled-in in network - -if [ ! -z $SYNTH ]; then - @CMAKE_CURRENT_BINARY_DIR@/src/dump_data --test --c2pitch @CMAKE_CURRENT_SOURCE_DIR@/wav/birch.wav birch.f32 - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } - echo "synth .f32 OK" - @CMAKE_CURRENT_BINARY_DIR@/src/test_lpcnet -l birch_states.f32 birch.f32 birch_out.raw - octave -p ../src --no-gui <<< "ret=compare_states('birch_states_targ.f32', 'birch_states.f32'); quit(ret)" - if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi - echo "synth states Octave OK" - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; } - echo "synth states OK" - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_out_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } - echo "synth .raw OK" -fi - -# Synthesis with the 20h network, loaded up at run time - -if [ ! -z $SYNTH_20h ]; then - @CMAKE_CURRENT_BINARY_DIR@/src/dump_data --test --c2pitch @CMAKE_CURRENT_SOURCE_DIR@/wav/birch.wav birch.f32 - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } - echo "synth .f32 OK" - @CMAKE_CURRENT_BINARY_DIR@/src/test_lpcnet -n @CMAKE_CURRENT_SOURCE_DIR@/unittest/lpcnet_20h.f32 -l birch_states.f32 birch.f32 birch_out.raw - octave -p ../src --no-gui <<< "ret=compare_states('birch_20h_states_targ.f32', 'birch_states.f32'); quit(ret)" - if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi - echo "synth states Octave OK" - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_20h_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; } - echo "synth states OK" - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/birch_20h_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } - echo "synth .raw OK" -fi - -# Testing log mag operation, using 190804a network. Not checking states in this test - -if [ ! -z $SYNTH_mag ]; then - @CMAKE_CURRENT_BINARY_DIR@/src/dump_data --mag --test --c2pitch @CMAKE_CURRENT_SOURCE_DIR@/wav/c01_01.wav c01_01.f32 - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/c01_01_mag.f32 c01_01.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; } - echo "mag .f32 OK" - @CMAKE_CURRENT_BINARY_DIR@/src/test_lpcnet --mag 1 -n @CMAKE_CURRENT_SOURCE_DIR@/unittest/lpcnet_190804a.f32 c01_01.f32 c01_01_out.raw - diff @CMAKE_CURRENT_SOURCE_DIR@/unittest/c01_01_190804a_targ.raw c01_01_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; } - echo "mag .raw OK" -fi - -echo "all tests PASSED"