When building this package, the tidl-build-tests is also built together.
Before building the codes, the tidl-build-tests generates the codes using tidlc.
The tidl files exist in the tests/buil_tests/tidl directory.
The unit_tests is moved to the tests/unit_tests.
Change-Id: I2816d93468582cdbf1aae3c067667104e3be3d52
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
IF(NOT DEFINED MINIMUM_BUILD)
ENABLE_TESTING()
-SET(TIDL_UNIT_TESTS tidl-unit-tests)
+SET(TARGET_TIDL_BUILD_TESTS "tidl-build-tests")
+SET(TIDL_UNIT_TESTS "tidl-unit-tests")
ADD_TEST(NAME ${TIDL_UNIT_TESTS} COMMAND ${TIDL_UNIT_TESTS} test.tidl test_error.tidl
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unit_tests)
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/unit_tests)
ENDIF(NOT DEFINED MINIMUM_BUILD)
ADD_SUBDIRECTORY(idlc)
-IF(NOT DEFINED MINIMUM_BUILD)
-ADD_SUBDIRECTORY(unit_tests)
-ADD_DEPENDENCIES(${TIDL_UNIT_TESTS} ${PROJECT_NAME})
-ENDIF(NOT DEFINED MINIMUM_BUILD)
+ADD_SUBDIRECTORY(tests)
BuildRequires: bison
BuildRequires: gtest-devel
BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(rpc-port)
+BuildRequires: pkgconfig(bundle)
%if 0%{?gcov:1}
BuildRequires: lcov
%endif
%__make %{?_smp_mflags}
%check
-ctest --output-on-failure %{?_smp_mflags}
+ctest -V %{?_smp_mflags}
%if 0%{?gcov:1}
lcov -c --ignore-errors graph --no-external -q -d . -o gcov.info
genhtml gcov.info
--- /dev/null
+IF(NOT DEFINED MINIMUM_BUILD)
+ADD_SUBDIRECTORY(unit_tests)
+ADD_DEPENDENCIES(${TIDL_UNIT_TESTS} ${PROJECT_NAME})
+
+ADD_SUBDIRECTORY(build_tests)
+ADD_DEPENDENCIES(${TARGET_TIDL_BUILD_TESTS} ${PROJECT_NAME})
+ENDIF(NOT DEFINED MINIMUM_BUILD)
--- /dev/null
+SET(TOOL_TIDLC "${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/tidlc")
+SET(TARGET_PREBUILD_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/prebuild.sh")
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PKGS REQUIRED dlog glib-2.0 rpc-port bundle)
+
+FOREACH(flag ${PKGS_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFALGS} -fPIE -Werror")
+SET(CMAKE_EXE_LINKER_FLAGS "-pie -Wl,--as-needed")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TIDL_BUILD_TESTS_SRCS)
+
+SET(TIDL_GEN_SRCS
+ BufferProxy.cc
+ BufferProxyC.c
+ BufferStub.cc
+ BufferStubC.c
+ DataPortProxy.cc
+ DataPortProxyC.c
+ DataPortStub.cc
+ DataPortStubC.c
+ ExProxy.cc
+ ExProxyC.c
+ ExStub.cc
+ ExStubC.c
+ MessageProxy.cc
+ MessageProxyC.c
+ MessageStub.cc
+ MessageStubC.c
+)
+
+ADD_CUSTOM_COMMAND(OUTPUT ${TIDL_GEN_SRCS} PRE_BUILD
+ COMMAND ${TARGET_PREBUILD_SCRIPT} ${TOOL_TIDLC} ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${TOOL_TIDLC}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+ADD_EXECUTABLE(${TARGET_TIDL_BUILD_TESTS}
+ ${TIDL_BUILD_TESTS_SRCS}
+ ${TIDL_GEN_SRCS}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_TIDL_BUILD_TESTS} ${PKGS_LDFLAGS} "-lpthread")
+
+INSTALL(TARGETS ${TARGET_TIDL_BUILD_TESTS} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2021 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>
+
+int main(int argc, char** argv) {
+ std::cout << "TIDL Build Test" << std::endl;
+ return 0;
+}
--- /dev/null
+#!/bin/bash
+
+SCRIPT_FILE=$(readlink -f $0)
+SCRIPT_DIR=$(dirname $SCRIPT_FILE)
+TIDLC=$1
+TARGET_DIR=$2
+
+FILES[0]="Message"
+FILES[1]="Buffer"
+FILES[2]="Ex"
+FILES[3]="DataPort"
+FILES[4]="Foo"
+
+GenerateTIDL() {
+ for index in ${!FILES[*]}; do
+ echo "Generate ${FILES[index]}"
+
+ INPUT="${FILES[index]}.tidl"
+ OUTPUT="${FILES[index]}Stub"
+ ${TIDLC} -s -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+ OUTPUT="${FILES[index]}Proxy"
+ ${TIDLC} -p -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+ OUTPUT="${FILES[index]}StubC"
+ ${TIDLC} -s -n -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+ OUTPUT="${FILES[index]}ProxyC"
+ ${TIDLC} -p -n -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+ done
+}
+
+GenerateTIDL
+
+echo "Done"
--- /dev/null
+interface IRemoteBuffer {
+ void BufEvent(array<char> buf) delegate;
+
+ int GetFirst(string id, BufEvent ev, int max_size);
+ int GetNext(string id);
+}
--- /dev/null
+struct CursorContext {
+ int Handle;
+}
+
+struct Pair {
+ string Key;
+ string Value;
+}
+
+interface DataPort {
+ CursorContext Query(string uri, list<string> projection, string selection, list<string> selectionArgs, string sortOrder);
+ int Insert(string uri, list<Pair> values);
+ int Update(string uri, list<Pair> values, string selection, list<string> selectionArgs);
+ int Delete(string uri, string selection, list<string> selectionArgs);
+
+ bool CursorIsLast(CursorContext cxt);
+ bool CursorMoveToFirst(CursorContext cxt);
+ bool CursorMoveToNext(CursorContext cxt);
+ string CursorGetString(CursorContext cxt, int column);
+ void CursorDispose(CursorContext cxt) async;
+}
--- /dev/null
+struct StructTest {
+ int Int;
+ short Short;
+ char Char;
+ bundle Bd;
+ bool Fg;
+ string Str;
+ float Float;
+ double Double;
+ long Long;
+}
+
+struct Student {
+ string name;
+ int num;
+ bundle data;
+ array<char> extra;
+}
+
+struct Class {
+ string name;
+ list<Student> students;
+}
+
+[privilege = "http://tizen.org/privilege/appmanager.launch", privilege = "http://tizen.org/privilege/mediastorage",
+trusted = "true"]
+interface School {
+ void ClassAddedCB(int ret) delegate;
+ int T1(out bool b);
+ int T2(out char c);
+ int T3(out int l);
+ int T4(ref bool b);
+ int T5(ref char c);
+ int T6(ref int l);
+ int T7(out string str);
+ int T8(ref string str);
+ int Test1(out StructTest st);
+ int Test2(StructTest st);
+ int Test3(ref StructTest st);
+ int Test4(out list<StructTest> st);
+ int Test5(list<StructTest> st);
+ int Test6(ref list<StructTest> st);
+
+ /// <summary>
+ /// Add class
+ /// </summary>
+ int AddClass(in Class cls);
+
+ /// <summary>
+ /// Add class async
+ /// </summary>
+ void AddClassAsync(Class cls, ClassAddedCB cb) async;
+
+ int GetStudent(in string c_name, in string s_name, out Student student);
+ int SetAllIds(list<list<int>> nums);
+ int SetExtra(string s_name, array<char> extra);
+}
--- /dev/null
+struct Foo {
+ int Age;
+ string Name;
+}
+
+interface Runnable {
+ int Run(Foo foo);
+ list<string> GetNames();
+}
--- /dev/null
+interface Message {
+ void NotifyCB(string sender, string msg) delegate;
+
+ int Register(string name, NotifyCB cb);
+ void Unregister() async;
+ int Send(string msg);
+}
LINK_DIRECTORIES(${GTEST_LIBRARY_DIRS})
SET(TIDLC_SOURCES
- ${CMAKE_SOURCE_DIR}/idlc/ast/document.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/declaration.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/interface.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/type.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/parameter.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/element.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/structure.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/block.cc
- ${CMAKE_SOURCE_DIR}/idlc/gen/generator.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/parser.cc
- ${CMAKE_SOURCE_DIR}/idlc/ast/attribute.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/document.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/declaration.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/interface.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/type.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/parameter.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/element.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/structure.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/block.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/gen/generator.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/parser.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/attribute.cc
)
ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
AUX_SOURCE_DIRECTORY(. UNIT_TESTS_SOURCES)
AUX_SOURCE_DIRECTORY(cs_gen CS_GEN_UNIT_TESTS_SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/idlc/gen CS_GEN_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/gen CS_GEN_SOURCES)
-FLEX_TARGET(TIDLC ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc.ll ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc_l.cpp)
-BISON_TARGET(TIDLC ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc.yy ${CMAKE_SOURCE_DIR}/idlc/ast/tidlc_y.cpp)
+FLEX_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc.ll
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc_l.cpp)
+BISON_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc.yy
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../idlc/ast/tidlc_y.cpp)
ADD_EXECUTABLE(${TIDL_UNIT_TESTS}
${BISON_TIDLC_OUTPUTS}