From 073a9402ae1f84a3b3cb45a5758b7c27b2970038 Mon Sep 17 00:00:00 2001 From: Parichay Kapoor Date: Fri, 25 Sep 2020 17:05:30 +0900 Subject: [PATCH] [app/test] Enable app-test with enable-test Enable application testing with enable-test only **Self evaluation:** 1. Build test: [x]Passed [ ]Failed [ ]Skipped 2. Run test: [x]Passed [ ]Failed [ ]Skipped Signed-off-by: Parichay Kapoor --- Applications/MNIST/jni/main.cpp | 12 ++++++++---- .../TransferLearning/Draw_Classification/jni/main.cpp | 16 ++++++++++++---- meson.build | 4 ++++ packaging/nntrainer.spec | 1 - 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Applications/MNIST/jni/main.cpp b/Applications/MNIST/jni/main.cpp index d1380b9..2484d12 100644 --- a/Applications/MNIST/jni/main.cpp +++ b/Applications/MNIST/jni/main.cpp @@ -19,6 +19,10 @@ * */ +#if defined(ENABLE_TEST) +#define APP_VALIDATE +#endif + #include #include #include @@ -29,7 +33,7 @@ #include #include -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) #include #endif @@ -235,7 +239,7 @@ int getBatch_val(float **outVec, float **outLabel, bool *last, return ML_ERROR_NONE; } -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) TEST(MNIST_training, verify_accuracy) { EXPECT_FLOAT_EQ(training_loss, 2.0374029); } @@ -290,7 +294,7 @@ int main(int argc, char *argv[]) { NN.readModel(); NN.setDataBuffer((DB)); -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) status = NN.setProperty({"epochs=5"}); if (status != ML_ERROR_NONE) { std::cerr << "Error setting the number of epochs" << std::endl; @@ -309,7 +313,7 @@ int main(int argc, char *argv[]) { return 0; } -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) try { testing::InitGoogleTest(&argc, argv); } catch (...) { diff --git a/Applications/TransferLearning/Draw_Classification/jni/main.cpp b/Applications/TransferLearning/Draw_Classification/jni/main.cpp index ad1132b..5e3fbef 100644 --- a/Applications/TransferLearning/Draw_Classification/jni/main.cpp +++ b/Applications/TransferLearning/Draw_Classification/jni/main.cpp @@ -27,14 +27,16 @@ * */ +#if defined(__TIZEN__) && defined(ENABLE_TEST) +#define APP_VALIDATE +#endif + #include #include #include #include #if defined(__TIZEN__) -#include - #include #include #include @@ -49,6 +51,10 @@ #include #endif +#if defined(APP_VALIDATE) +#include +#endif + #include "bitmap_helpers.h" #include @@ -80,10 +86,12 @@ const char *label_names[LABEL_SIZE] = {"happy", "sad", "soso"}; float inputVector[EPOCH_SIZE][INPUT_SIZE]; float labelVector[EPOCH_SIZE][LABEL_SIZE]; +#if defined(APP_VALIDATE) /** Benchmark output values */ const float test_output_benchmark[TOTAL_TEST_SIZE] = { 0.99669778, 0.96033746, 0.99192446, 0.98053128, 0.95911789, 0.99331927, 0.55696899, 0.46636438}; +#endif /** Container to hold the output values when running */ float test_output[TOTAL_TEST_SIZE]; @@ -575,7 +583,7 @@ fail_exit: #endif } -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) /** * @brief Test to verify that the draw classification app is successful */ @@ -645,7 +653,7 @@ int main(int argc, char *argv[]) { set_feature_state(NOT_CHECKED_YET); #endif -#if defined(__TIZEN__) +#if defined(APP_VALIDATE) try { testing::InitGoogleTest(&argc, argv); } catch (...) { diff --git a/meson.build b/meson.build index a77bb62..ed999e0 100644 --- a/meson.build +++ b/meson.build @@ -107,6 +107,10 @@ if get_option('enable-logging') add_project_arguments('-D__LOGGING__=1', language:['c','cpp']) endif +if get_option('enable-test') + add_project_arguments('-DENABLE_TEST=1', language:['c','cpp']) +endif + libm_dep = cxx.find_library('m') # cmath library libdl_dep = cxx.find_library('dl') # DL library thread_dep = dependency('threads') # pthread for tensorflow-lite diff --git a/packaging/nntrainer.spec b/packaging/nntrainer.spec index d339047..9cbd930 100644 --- a/packaging/nntrainer.spec +++ b/packaging/nntrainer.spec @@ -221,7 +221,6 @@ rm -rf model.bin cp ../Applications/MNIST/jni/mnist_trainingSet.dat . MNIST_APP=Applications/MNIST ./${MNIST_APP}/jni/nntrainer_mnist ../${MNIST_APP}/res/mnist.ini - popd # unittest for nntrainer plugin for nnstreamer -- 2.7.4