ADD_SUBDIRECTORY(tests/integration-test)
ADD_SUBDIRECTORY(tests/haltest)
+ADD_SUBDIRECTORY(tests/unittest)
+
ADD_SUBDIRECTORY(lib)
cp %{SOURCE2} .
make %{?jobs:-j%jobs}
+%check
+(cd tests/unittest && LD_LIBRARY_PATH=../../ ctest -V)
+
%install
rm -rf %{buildroot}
%make_install
--- /dev/null
+ENABLE_TESTING()
+SET(PASS_UNITTEST "pass-unittests")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Werror")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ PASS_UNITTEST_SRCS)
+ADD_EXECUTABLE(${PASS_UNITTEST} ${PASS_UNITTEST_SRCS})
+
+TARGET_INCLUDE_DIRECTORIES(${PASS_UNITTEST} PUBLIC
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../include"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/src"
+ "${CMAKE_SOURCE_DIR}/src/pass"
+ "${CMAKE_SOURCE_DIR}/include"
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pass_unittest_pkgs REQUIRED
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+ json-c
+ hal-api-power
+)
+
+FOREACH(flag ${pass_unittest_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+TARGET_LINK_LIBRARIES(${PASS_UNITTEST} ${pass_unittest_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES COMPILE_FLAGS "-fPIE -fvisibility=default")
+SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES LINK_FLAGS "-pie")
+
+ADD_TEST(
+ NAME ${PASS_UNITTEST}
+ COMMAND ${PASS_UNITTEST}
+)
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#include <iostream>
+#include <unistd.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+int main(int argc, char *argv[])
+{
+ try {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+ } catch (...) {
+ return EXIT_FAILURE;
+ }
+}