Make pkginfo-server restart after pkgmgr info is changed. 09/280409/6
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 29 Aug 2022 15:09:23 +0000 (17:09 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 1 Sep 2022 04:59:08 +0000 (06:59 +0200)
 "I'm a product
  Of my environment
  So don't blame me, I just work here"

              - Offspring, "Americana"

Tests mimic application installation by altering sqlite DB manually.

This however, leaves pkginfo-server daemons' internal cache in bad state,
not maching the DB, effectively making changes not visible to its clients.

This patch is an obscene attempt to fix this terrible issue by killig
that daemon after completing the DB modiffications.

With this change, unit tests should all pass again (6 were failing before).

Proper solution to the problem would probably require installing regular
small applications in place of mimicking their installation, which
would be a much, much bigger and time-costly refactoring.

Also, added more debug information.

Change-Id: I826bde1e56001d87ddbaeee5efe4f03ade32db42

capi/src/privilege_package_info.c
test/tc-common.c

index d83c1976205462203642484d452cc0f512b0fbf2..85a4342b57ad1f6915bab16a397e792d75cec9de 100644 (file)
@@ -119,7 +119,7 @@ static int __get_pkg_type(uid_t uid, const char *pkgid, privilege_manager_packag
        pkgmgrinfo_pkginfo_h handle = NULL;
        ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
        if (ret != PMINFO_R_OK) {
-               LOGE("failed to get pkginfo handle! pkgid <%s>", pkgid);
+               LOGE("failed to get pkginfo handle! pkgid <%s>, <%d>", pkgid, ret);
                return -1;
        }
        ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
index 89fe19fb424f75d8597b3b77977130ec3828bcae..938662e1b8a53d6888d5a0a219de24bfa4c7aac7 100644 (file)
@@ -63,6 +63,9 @@ void __set_privacy_test_pkg_info()
        if (ret != 0)
                printf_red("failed to set pkg info. ret = %d\n", ret);
 
+       ret = system("systemctl restart pkgmgr-info");
+       if (ret != 0)
+               printf_red("failed to reload pkgmgr-info");
 }
 
 void __unset_privacy_test_pkg_info()
@@ -71,6 +74,9 @@ void __unset_privacy_test_pkg_info()
        if (ret != 0)
                printf_red("failed to unset pkg info\n");
 
+       ret = system("systemctl restart pkgmgr-info");
+       if (ret != 0)
+               printf_red("failed to reload pkgmgr-info");
 }
 
 /* error enum to string */