@@ -681,6 +681,11 @@ struct BuildMMapWeightCacheProviderTest : testing::TestWithParam<TestVariant> {
681681 enum { kBufferId1 , kBufferId2 , kBufferId3 , kBufferId4 };
682682
683683 void SetUp () override {
684+ if (use_in_memory_cache &&
685+ !TfLiteXNNPackDelegateCanUseInMemoryWeightCacheProvider ()) {
686+ GTEST_SKIP () << " In-memory weight cache isn't enabled for this build or "
687+ " isn't supported by the current system, skipping test." ;
688+ }
684689 AddTensors ();
685690 EndSetup ();
686691 }
@@ -833,6 +838,10 @@ struct LoadMMapWeightCacheProviderTest : BuildMMapWeightCacheProviderTest {
833838
834839 void SetUp () override {
835840 BuildMMapWeightCacheProviderTest::SetUp ();
841+ if (IsSkipped ()) {
842+ return ;
843+ }
844+
836845 ASSERT_TRUE (cache_provider.StartBuildStep ());
837846
838847 pack_id_1 = ctx.PackTensors (&cache_provider.GetCacheProvider (), kAlgoSeed1 ,
@@ -889,6 +898,13 @@ TEST_P(LoadMMapWeightCacheProviderTest, LookUpSucceeds) {
889898}
890899
891900struct MMapWeightCacheProviderTest : testing::TestWithParam<TestVariant> {
901+ void SetUp () override {
902+ if (use_in_memory_cache &&
903+ !TfLiteXNNPackDelegateCanUseInMemoryWeightCacheProvider ()) {
904+ GTEST_SKIP () << " In-memory weight cache isn't enabled for this build or "
905+ " isn't supported by the current system, skipping test." ;
906+ }
907+ }
892908 bool use_explicit_fd = GetParam().use_explicit_fd;
893909 const char * const explicit_fd_path = GetParam().explicit_fd_path;
894910 const bool use_in_memory_cache = GetParam().use_in_memory_cache;
0 commit comments