}
/**
+ * @brief test getNPU_requestModel
+ */
+TEST (ne_libnpuhost_test, request_get_model) {
+ npudev_h dev;
+ uint32_t modelid, modelid2;
+
+ std::string model_dir (NE_DATADIR);
+ model_dir += "/testdata/TRIV235_2TOPS/CONV_2D_000";
+
+ std::string model_path = model_dir + "/model.tvn";
+
+ off_t model_size = get_file_size (model_path.c_str ());
+ if (model_size <= 0)
+ /* skip */
+ return;
+
+ generic_buffer modelfile;
+ modelfile.type = BUFFER_FILE;
+ modelfile.filepath = model_path.c_str ();
+ modelfile.size = model_size;
+
+ ASSERT_EQ (getNPUdeviceByTypeAny (&dev, NPUCOND_TRIV2_CONN_SOCIP, 2), 0);
+ ASSERT_EQ (registerNPUmodel (dev, &modelfile, &modelid), 0);
+
+ int req_id;
+ ASSERT_EQ (createNPU_request (dev, modelid, &req_id), 0);
+
+ EXPECT_EQ (getNPU_requestModel (dev, req_id, &modelid2), 0);
+ EXPECT_EQ (modelid, modelid2);
+
+ ASSERT_EQ (removeNPU_request (dev, req_id), 0);
+ ASSERT_EQ (unregisterNPUmodel (dev, modelid), 0);
+ putNPUdevice (dev);
+}
+
+/**
+ * @brief test getNPU_requestModel with error handling
+ */
+TEST (ne_libnpuhost_test, request_get_model_n) {
+ npudev_h dev;
+ uint32_t modelid;
+ int req_id;
+
+ ASSERT_EQ (getNPUdeviceByTypeAny (&dev, NPUCOND_TRIV2_CONN_SOCIP, 2), 0);
+ /* invalid req_id */
+ EXPECT_NE (getNPU_requestModel (dev, -1, &modelid), 0);
+
+ std::string model_dir (NE_DATADIR);
+ model_dir += "/testdata/TRIV235_2TOPS/CONV_2D_000";
+
+ std::string model_path = model_dir + "/model.tvn";
+
+ off_t model_size = get_file_size (model_path.c_str ());
+ if (model_size <= 0)
+ /* skip */
+ return;
+
+ generic_buffer modelfile;
+ modelfile.type = BUFFER_FILE;
+ modelfile.filepath = model_path.c_str ();
+ modelfile.size = model_size;
+
+ ASSERT_EQ (registerNPUmodel (dev, &modelfile, &modelid), 0);
+ ASSERT_EQ (createNPU_request (dev, modelid, &req_id), 0);
+ /* empty modelid */
+ EXPECT_NE (getNPU_requestModel (dev, req_id, nullptr), 0);
+
+ ASSERT_EQ (removeNPU_request (dev, req_id), 0);
+ ASSERT_EQ (unregisterNPUmodel (dev, modelid), 0);
+ putNPUdevice (dev);
+}
+
+/**
+ * @brief test log APIs
+ */
+TEST (ne_libnpuhost_test, write_logs) {
+ npu_loglevel levels[] = {
+ NPU_LOG_ERROR,
+ NPU_LOG_WARN,
+ NPU_LOG_INFO,
+ };
+
+ for (auto &level : levels)
+ EXPECT_EQ (writeNPU_log (level, "TEST", "testing logs..."), 0);
+}
+
+/**
+ * @brief test log APIs with error handling
+ */
+TEST (ne_libnpuhost_test, write_logs_n) {
+ EXPECT_NE (writeNPU_log (NPU_LOG_NONE, "TEST", "testing logs..."), 0);
+ EXPECT_NE (writeNPU_log (NPU_LOG_END, "TEST", "testing logs..."), 0);
+ EXPECT_NE (writeNPU_log (NPU_LOG_ERROR, nullptr, "testing logs..."), 0);
+ EXPECT_NE (writeNPU_log (NPU_LOG_ERROR, "TEST", nullptr), 0);
+}
+
+/**
* @brief main function for unit test
*/
int