#include <memory>
#include <mutex>
#include <fstream>
+#include <atomic>
#include <dpl/test/test_runner_child.h>
#include <dpl/test/test_runner.h>
constexpr size_t arraySize(T (&)[N]) { return N; }
} // namespace
+RUNNER_TEST(security_manager_190_prepare_app_threads_malloc)
+{
+ TemporaryTestUser tmpUser(APP_TEST_USER, GUM_USERTYPE_NORMAL, false);
+ tmpUser.create();
+
+ const auto uid = tmpUser.getUid();
+
+ AppInstallHelper app("app190", uid);
+
+ ScopedInstaller installer(app);
+
+ const auto pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed");
+
+ if (pid == 0) {
+ RUNNER_ASSERT_ERRNO_MSG(setLauncherSecurityAttributes(tmpUser) == 0, "launcher failed");
+
+ const auto appId = app.getAppId();
+
+ Api::prepareAppCandidate();
+
+ std::atomic<bool> quit = false;
+ static constexpr size_t MAX = 60;
+ std::vector<std::thread> threads;threads.reserve(MAX);
+ for (size_t i = 0; i < MAX; i++ ) {
+ threads.emplace_back(std::thread([&](){
+ while(!quit) {
+ auto tmp = malloc(1000);
+ usleep(100);
+ free(tmp);
+ }
+ }));
+ }
+
+ Api::prepareApp(appId);
+ quit = true;
+ for (size_t i = 0; i < MAX; i++ )
+ threads[i].join();
+ exit(0);
+ }
+ waitPid(pid);
+ Api::cleanupApp(app.getAppId(), uid, pid);
+}
+
RUNNER_TEST(security_manager_200_prepare_app_perf)
{
constexpr int8_t nThreads = 32;