[app/test] Enable app-test with enable-test
authorParichay Kapoor <pk.kapoor@samsung.com>
Fri, 25 Sep 2020 08:05:30 +0000 (17:05 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Fri, 25 Sep 2020 10:12:13 +0000 (19:12 +0900)
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 <pk.kapoor@samsung.com>
Applications/MNIST/jni/main.cpp
Applications/TransferLearning/Draw_Classification/jni/main.cpp
meson.build
packaging/nntrainer.spec

index d1380b9..2484d12 100644 (file)
  *
  */
 
+#if defined(ENABLE_TEST)
+#define APP_VALIDATE
+#endif
+
 #include <climits>
 #include <cmath>
 #include <fstream>
@@ -29,7 +33,7 @@
 #include <stdlib.h>
 #include <time.h>
 
-#if defined(__TIZEN__)
+#if defined(APP_VALIDATE)
 #include <gtest/gtest.h>
 #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 (...) {
index ad1132b..5e3fbef 100644 (file)
  *
  */
 
+#if defined(__TIZEN__) && defined(ENABLE_TEST)
+#define APP_VALIDATE
+#endif
+
 #include <limits.h>
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
 
 #if defined(__TIZEN__)
-#include <gtest/gtest.h>
-
 #include <nnstreamer-single.h>
 #include <nnstreamer.h>
 #include <nntrainer_internal.h>
 #include <iostream>
 #endif
 
+#if defined(APP_VALIDATE)
+#include <gtest/gtest.h>
+#endif
+
 #include "bitmap_helpers.h"
 #include <nntrainer.h>
 
@@ -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 (...) {
index a77bb62..ed999e0 100644 (file)
@@ -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
index d339047..9cbd930 100644 (file)
@@ -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