%defattr(-, root, root, -)
/usr/bin/security-tests.sh
/usr/bin/security-tests-all.sh
+/usr/bin/tests-summary.sh
/usr/bin/test-performance-check.sh
/usr/bin/perf
WORLD_EXECUTE
)
+INSTALL(FILES ${PROJECT_SOURCE_DIR}/tests/tests-summary.sh
+ DESTINATION bin
+ PERMISSIONS OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ GROUP_EXECUTE
+ WORLD_READ
+ WORLD_EXECUTE
+ )
+
INSTALL(FILES
${PROJECT_SOURCE_DIR}/tests/test-performance-check.sh
${PROJECT_SOURCE_DIR}/tests/perf
${PROJECT_SOURCE_DIR}/tests/common/tests_common.cpp
${PROJECT_SOURCE_DIR}/tests/common/access_provider.cpp
${PROJECT_SOURCE_DIR}/tests/common/smack_access.cpp
+ ${PROJECT_SOURCE_DIR}/tests/common/summary_collector.cpp
)
#header directories
--- /dev/null
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file summary_collector.cpp
+ * @author Michal Witanowski (m.witanowski@samsung.com)
+ * @version 1.0
+ * @brief Implementation of custom test results collector needed by summary view.
+ */
+
+#include <summary_collector.h>
+#include <fstream>
+
+namespace {
+ const char* summaryFileName = "/tmp/security-tests-summary-file";
+ const char* summaryCollectorName = "summary";
+};
+
+SummaryCollector::SummaryCollector()
+{
+ Start();
+}
+
+
+// Overrides DPL::Test::TestResultsCollectorBase::Start() virtual method.
+void SummaryCollector::Start()
+{
+ m_total = m_succeeded = m_failed = m_ignored = 0;
+}
+
+// append results to the file
+void SummaryCollector::Finish()
+{
+ std::ofstream outputFile;
+ outputFile.open(summaryFileName, std::ofstream::out | std::ofstream::app);
+ if (!outputFile)
+ return; //failed to open file
+
+ outputFile << m_total << ' '
+ << m_succeeded << ' '
+ << m_failed << ' '
+ << m_ignored << std::endl;
+ outputFile.close();
+}
+
+void SummaryCollector::CollectResult(const std::string& /*id*/,
+ const std::string& /*description*/,
+ const FailStatus::Type status,
+ const std::string& /*reason = ""*/)
+{
+ switch (status) {
+ case FailStatus::IGNORED: ++m_ignored; break;
+ case FailStatus::INTERNAL: // internal error count as fail
+ case FailStatus::FAILED: ++m_failed; break;
+ case FailStatus::NONE: ++m_succeeded; break;
+ };
+ ++m_total;
+}
+
+DPL::Test::TestResultsCollectorBase* SummaryCollector::Constructor()
+{
+ return new SummaryCollector();
+}
+
+void SummaryCollector::Register()
+{
+ //register custom results collector
+ DPL::Test::TestResultsCollectorBase::RegisterCollectorConstructor(summaryCollectorName,
+ &SummaryCollector::Constructor);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file summary_collector.h
+ * @author Michal Witanowski (m.witanowski@samsung.com)
+ * @version 1.0
+ * @brief Implementation of custom test results collector needed by summary view.
+ */
+
+#ifndef _RAW_RESULTS_COLLECTOR_H_
+#define _RAW_RESULTS_COLLECTOR_H_
+
+#include <dpl/test/test_results_collector.h>
+
+/*
+ * Custom test runner results collector. The results (total test cases, failed, etc.) are
+ * appended to a file, wihich is parsed after execution of all tests in oreder to
+ * display summary view.
+ */
+class SummaryCollector : public DPL::Test::TestResultsCollectorBase
+{
+ unsigned int m_total, m_succeeded, m_failed, m_ignored; // counters
+
+ SummaryCollector();
+ void Start();
+ void Finish();
+ void CollectResult(const std::string& /*id*/,
+ const std::string& /*description*/,
+ const FailStatus::Type status,
+ const std::string& /*reason = ""*/);
+
+public:
+ static TestResultsCollectorBase* Constructor();
+ static void Register();
+};
+
+#endif
#include <dpl/test/test_runner.h>
#include <dpl/log/log.h>
+#include <summary_collector.h>
int main (int argc, char *argv[])
{
LogInfo("Starting libprivilege-control tests");
+
+ SummaryCollector::Register();
int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
return status;
}
* @brief libsmack test runer
*/
#include <dpl/test/test_runner.h>
+#include <summary_collector.h>
int main (int argc, char *argv[])
{
+ SummaryCollector::Register();
int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
return status;
}
#include <unistd.h>
#include <memory>
#include "security_server_mockup.h"
+#include <summary_collector.h>
/*Number of calls in a single test*/
#define NUMBER_OF_CALLS (5)
int main(int argc, char *argv[])
{
+ SummaryCollector::Register();
securityClientEnableLogSystem();
DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
return 0;
#include "security_server_mockup.h"
#include <security-server.h>
-
#include <access_provider.h>
#include <tracker.h>
-
#include "tests_common.h"
+#include <summary_collector.h>
+
#define PROPER_COOKIE_SIZE 20
int main(int argc, char *argv[])
{
- return
- DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+ SummaryCollector::Register();
+ return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
}
#include <dbus/dbus.h>
#include <dbus-glib.h>
#include <glib-object.h>
+#include <summary_collector.h>
#include "tests_common.h"
#include "security-server.h"
#include "privilege-control.h"
int main(int argc, char *argv[])
{
- int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-
- return status;
+ SummaryCollector::Register();
+ return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
}
#include <dlog.h>
#include "security_server_clean_env.h"
#include <tracker.h>
+#include <summary_collector.h>
// security server retry timeout in microseconds
int main(int argc, char *argv[])
{
- int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-
- return status;
+ SummaryCollector::Register();
+ return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
}
#include <dpl/test/test_runner.h>
#include <dpl/test/test_runner_multiprocess.h>
#include <tests_common.h>
+#include <summary_collector.h>
#include <iostream>
#include <sys/smack.h>
#include <cstddef>
#include <sys/types.h>
#include "security-server.h"
-
std::mutex g_mutex;
std::mutex g_msgMutex;
size_t g_successes = 0;
int main (int argc, char *argv[])
{
- int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
- return status;
+ SummaryCollector::Register();
+ return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
}
#include "tests_common.h"
#include <smack_access.h>
#include <access_provider.h>
+#include <summary_collector.h>
const char *TEST03_SUBJECT = "subject_0f09f7cc";
const char *TEST04_SUBJECT = "subject_57dfbfc5";
printf("Error: %s must be executed by root\n", argv[0]);
exit(1);
}
+ SummaryCollector::Register();
return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
}
#!/bin/sh
echo "[Trigerring all tests...]"
+summary_file="/tmp/security-tests-summary-file"
+
+#delete summary file
+rm -f $summary_file
+
ign="--runignored"
if [ $# -gt 0 ]; then
if [ "$1" = "--noignored" ]; then
fi
fi
-security-tests.sh smack --output=text $ign
-security-tests.sh libprivilege-control --output=text $ign
-security-tests.sh ss-clientsmack --output=text $ign
-security-tests.sh ss-server --output=text $ign
-security-tests.sh ss-password --output=text $ign
-security-tests.sh ss-dbus --output=text $ign
-security-tests.sh ss-stress --output=text $ign
+# 'text' - console output
+# 'summary' - used for summary view
+security-tests.sh smack --output=text --output=summary $ign
+security-tests.sh libprivilege-control --output=text --output=summary $ign
+security-tests.sh ss-clientsmack --output=text --output=summary $ign
+security-tests.sh ss-server --output=text --output=summary $ign
+security-tests.sh ss-password --output=text --output=summary $ign
+security-tests.sh ss-dbus --output=text --output=summary $ign
+security-tests.sh ss-stress --output=text --output=summary $ign
+
+# print summary
+tests-summary.sh $summary_file
+
echo "[Done]"
echo "========================================================================="
echo $1
echo
- libsmack-test $2 $3
+ libsmack-test "${@:2}" # propagate all remaining arguments (except first)
;;
"libprivilege-control")
echo "========================================================================="
echo $1
echo
- libprivilege-control-test $2 $3
+ libprivilege-control-test "${@:2}"
;;
"ss-clientsmack")
echo "========================================================================="
echo "SECURITY SERVER TEST CLIENT SMACK"
echo
- security-server-tests-client-smack $2 $3
+ security-server-tests-client-smack "${@:2}"
;;
"ss-stress")
echo "========================================================================="
echo "SECURITY SERVER TEST STRESS"
echo
- security-server-tests-stress $2 $3
+ security-server-tests-stress "${@:2}"
;;
"ss-server")
echo "========================================================================="
echo "SECURITY SERVER TEST SERVER"
echo
- security-server-tests-server $2 $3
+ security-server-tests-server "${@:2}"
;;
"ss-api-speed")
echo "========================================================================="
echo "SECURITY SERVER MEASURER SERVER"
echo
- security-server-tests-api-speed $2 $3
+ security-server-tests-api-speed "${@:2}"
;;
"ss-password")
echo "========================================================================="
echo "SECURITY SERVER TEST PASSWORD"
echo
- security-server-tests-password $2 $3
+ security-server-tests-password "${@:2}"
;;
"ss-dbus")
echo "========================================================================="
echo "SECURITY SERVER TEST DBUS"
echo
- security-server-tests-dbus $2 $3
+ security-server-tests-dbus "${@:2}"
;;
*)
echo "Correct using:"
--- /dev/null
+#!/bin/sh
+
+# sum up columns
+total=$(awk '{counter += $1} END {print counter}' "$1" )
+succeeded=$(awk '{counter += $2} END {print counter}' "$1" )
+failed=$(awk '{counter += $3} END {print counter}' "$1" )
+ignored=$(awk '{counter += $4} END {print counter}' "$1" )
+
+#color constants
+COLOR_GREEN_START="\033[1;32m"
+COLOR_DARK_GREEN_START="\033[0;36m"
+COLOR_END="\033[m"
+
+printf $COLOR_GREEN_START
+printf "Summary\n"
+printf $COLOR_END
+
+printf $COLOR_DARK_GREEN_START
+printf " Total: %i\n" $total
+printf " Succeeded: %i\n" $succeeded
+printf " Failed: %i\n" $failed
+printf " Ignored: %i\n" $ignored
+printf $COLOR_END
+
+printf "\n"