diff --git a/tensorflow/lite/testing/generated_examples_zip_test.cc b/tensorflow/lite/testing/generated_examples_zip_test.cc index c172e9b571f6d20bf9d9d1169008b97f531e0a9c..9ba0cffe5f504f27e86cdb0199dcda973adc09b8 100644 --- a/tensorflow/lite/testing/generated_examples_zip_test.cc +++ b/tensorflow/lite/testing/generated_examples_zip_test.cc @@ -292,9 +292,13 @@ class OpsTest : public ::testing::TestWithParam {}; TEST_P(OpsTest, RunZipTests) { string test_path_and_label = GetParam(); + string test_path = test_path_and_label; + string label = test_path_and_label; size_t end_pos = test_path_and_label.find(" "); - string test_path = test_path_and_label.substr(0, end_pos); - string label = test_path_and_label.substr(end_pos + 1); + if (end_pos != string::npos) { + test_path = test_path_and_label.substr(0, end_pos); + label = test_path_and_label.substr(end_pos + 1); + } string tflite_test_case = test_path + "_tests.txt"; string tflite_dir = test_path.substr(0, test_path.find_last_of("/")); string test_name = label.substr(label.find_last_of('/')); diff --git a/tensorflow/lite/testing/zip_test_utils.py b/tensorflow/lite/testing/zip_test_utils.py index 91bac6600a9d2a4b019019d2c997e9d01c9b1362..1b4460461b6d099e07072aae184b13c20867c3aa 100644 --- a/tensorflow/lite/testing/zip_test_utils.py +++ b/tensorflow/lite/testing/zip_test_utils.py @@ -350,7 +350,11 @@ def make_zip_of_tests(options, "%s=%r" % z for z in sorted(zip(keys, curr))).replace(" ", "")) if label[0] == "/": label = label[1:] - zip_path_label = label_base_path.replace(".zip", "_") + str(i) + + zip_path_label = label + if len(os.path.basename(zip_path_label)) > 245: + zip_path_label = label_base_path.replace(".zip", "_") + str(i) + i += 1 if label in processed_labels: # Do not populate data for the same label more than once. It will cause @@ -493,7 +497,11 @@ def make_zip_of_tests(options, archive.writestr(zip_path_label + "_tests.txt", example_fp2.getvalue(), zipfile.ZIP_DEFLATED) - zip_manifest.append(zip_path_label + " " + label + "\n") + zip_manifest_label = zip_path_label + " " + label + if zip_path_label == label: + zip_manifest_label = zip_path_label + + zip_manifest.append(zip_manifest_label + "\n") return tflite_model_binary, report