2323
2424using namespace std ;
2525
26- TEST (RteModelTest , PackRegistry) {
26+ TEST_F (RteModelTestConfig , PackRegistry) {
2727
2828 // tests for pack registry
2929 RteKernelSlim rteKernel; // here just to instantiate XMLTree parser
@@ -52,11 +52,11 @@ TEST(RteModelTest, PackRegistry) {
5252
5353}
5454
55- TEST (RteModelTest , PackRegistryLoadPacks) {
55+ TEST_F (RteModelTestConfig , PackRegistryLoadPacks) {
5656
5757 // tests for pack registry
5858 RteKernelSlim rteKernel; // here just to instantiate XMLTree parser
59- rteKernel.SetCmsisPackRoot (RteModelTestConfig::CMSIS_PACK_ROOT );
59+ rteKernel.SetCmsisPackRoot (packsDir );
6060
6161 RtePackRegistry* packRegistry = rteKernel.GetPackRegistry ();
6262 ASSERT_TRUE (packRegistry != nullptr );
@@ -65,24 +65,29 @@ TEST(RteModelTest, PackRegistryLoadPacks) {
6565 list<string> files;
6666 rteKernel.GetEffectivePdscFiles (files, false );
6767 EXPECT_FALSE (files.empty ());
68- list<RtePackage*> packs;
68+ const string& firstFile = *files.begin ();
69+ list<RtePackage*> packs, packs1;
6970 EXPECT_TRUE (rteKernel.LoadPacks (files, packs, &testModel));
7071 EXPECT_FALSE (packs.empty ());
7172 EXPECT_EQ (packs.size (), files.size ());
7273 EXPECT_EQ (packRegistry->GetLoadedPacks ().size (), packs.size ());
73- // to check if packs are the same or reloaded, modify the first pack
74+ // no reload by default
75+ EXPECT_TRUE (rteKernel.LoadPacks (files, packs1, &testModel));
76+ EXPECT_EQ (packs, packs1); // no new packs loaded
77+ packs1.clear ();
78+
79+ // to check if packs are the same or reloaded, modify the first pack
7480 ASSERT_NE (packs.begin (), packs.end ());
7581 RtePackage* pack = *(packs.begin ());
7682 ASSERT_TRUE (pack != nullptr );
7783 RteItem* dummyChild = new RteItem (" dummy_child" , pack);
7884 pack->AddItem (dummyChild);
7985 // no reload of the same files by default
80- list<RtePackage*> packs1;
8186 EXPECT_TRUE (rteKernel.LoadPacks (files, packs1, &testModel));
8287 EXPECT_EQ (packs1.size (), files.size ());
8388 EXPECT_EQ (packs, packs1); // no new packs loaded
8489 ASSERT_NE (packs1.begin (), packs1.end ());
85- auto pack1 = *packs1.begin ();
90+ RtePackage* pack1 = *( packs1.begin () );
8691 ASSERT_TRUE (pack1 != nullptr );
8792
8893 EXPECT_EQ (pack1->GetFirstChild (" dummy_child" ), dummyChild);
@@ -94,8 +99,6 @@ TEST(RteModelTest, PackRegistryLoadPacks) {
9499 EXPECT_EQ (pack1->GetFirstChild (" dummy_child" ), nullptr ); // pack got loaded again => no added child
95100
96101 EXPECT_EQ (packRegistry->GetLoadedPacks ().size (), files.size ());
97- ASSERT_NE (files.begin (), files.end ());
98- const string& firstFile = *files.begin ();
99102 pack = packRegistry->GetPack (firstFile);
100103 ASSERT_TRUE (pack != nullptr );
101104 EXPECT_EQ (pack->GetPackageState (), PackageState::PS_INSTALLED);
@@ -104,8 +107,25 @@ TEST(RteModelTest, PackRegistryLoadPacks) {
104107 EXPECT_FALSE (packRegistry->ErasePack (firstFile)); // already not in collection
105108 packs.clear ();
106109 EXPECT_TRUE (rteKernel.LoadPacks (files, packs, &testModel));
107- EXPECT_EQ (packs.size (), packs1.size ()); // only one pack is loaded
110+ EXPECT_EQ (packs.size (), packs1.size ()); // the pack is reloaded()
108111 packs.clear ();
112+ packs1.clear ();
113+
114+ EXPECT_TRUE (rteKernel.LoadPacks (files, packs, &testModel));
115+ // modify a file time stamp reloading
116+ string buf;
117+ pack = *(packs.begin ());
118+ dummyChild = new RteItem (" dummy_child" , pack);
119+ pack->AddItem (dummyChild);
120+ auto t = pack->GetModificationTime () - std::chrono::seconds (5 );
121+ EXPECT_TRUE (pack->SetModificationTime (t));
122+ EXPECT_FALSE (pack->SetModificationTime (t)); // to check return value
123+
124+ EXPECT_TRUE (rteKernel.LoadPacks (files, packs1, &testModel));
125+ pack1 = *(packs1.begin ());
126+ auto t1 = pack1->GetModificationTime ();
127+ EXPECT_NE (t, t1);
128+ EXPECT_EQ (pack1->GetFirstChild (" dummy_child" ), nullptr ); // pack got loaded again => no added child
109129}
110130
111131TEST (RteModelTest, LoadPacks) {
0 commit comments