MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST_P

Function TEST_P

tensorflow/lite/testing/generated_examples_zip_test.cc:260–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258class OpsTest : public ::testing::TestWithParam<string> {};
259
260TEST_P(OpsTest, RunZipTests) {
261 string test_path = GetParam();
262 string tflite_test_case = test_path + "_tests.txt";
263 string tflite_dir = test_path.substr(0, test_path.find_last_of("/"));
264 string test_name = test_path.substr(test_path.find_last_of('/'));
265
266 std::ifstream tflite_stream(tflite_test_case);
267 ASSERT_TRUE(tflite_stream.is_open()) << tflite_test_case;
268 tflite::testing::TfLiteDriver test_driver(
269 FLAGS_use_nnapi ? TfLiteDriver::DelegateType::kNnapi
270 : TfLiteDriver::DelegateType::kNone);
271
272 if (test_path.find("fully_quantize=True") != std::string::npos) {
273 // TODO(b/134594898): Tighten this constraint.
274 test_driver.SetThreshold(5e-1f, 4e-1f);
275 }
276
277 test_driver.SetModelBaseDir(tflite_dir);
278
279 auto broken_tests = kBrokenTests;
280 if (FLAGS_use_nnapi) {
281 broken_tests.insert(kBrokenNnapiTests.begin(), kBrokenNnapiTests.end());
282 }
283
284 string bug_number;
285 for (const auto& p : broken_tests) {
286 if (RE2::PartialMatch(test_name, p.first)) {
287 bug_number = p.second;
288 }
289 }
290
291 bool result = tflite::testing::ParseAndRunTests(&tflite_stream, &test_driver);
292 string message = test_driver.GetErrorMessage();
293 if (bug_number.empty()) {
294 if (FLAGS_use_nnapi && FLAGS_ignore_unsupported_nnapi && !result) {
295 EXPECT_EQ(message, string("Failed to invoke interpreter")) << message;
296 } else {
297 EXPECT_TRUE(result) << message;
298 }
299 } else {
300 if (FLAGS_ignore_known_bugs) {
301 EXPECT_FALSE(result) << "Test was expected to fail but is now passing; "
302 "you can mark http://b/"
303 << bug_number << " as fixed! Yay!";
304 } else {
305 EXPECT_TRUE(result) << message << ": Possibly due to http://b/"
306 << bug_number;
307 }
308 }
309}
310
311struct ZipPathParamName {
312 template <class ParamType>

Callers

nothing calls this directly

Calls 9

GetParamFunction · 0.85
ParseAndRunTestsFunction · 0.85
SetThresholdMethod · 0.80
SetModelBaseDirMethod · 0.80
findMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected