Add libinput haltests frame
authordyamy-lee <dyamy.lee@samsung.com>
Wed, 21 Apr 2021 06:35:11 +0000 (15:35 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:46:15 +0000 (14:46 +0900)
It generate the libinput haltests rpm package successfullty for testing input devices in hal by adding build configuration and packaging configuration.
It test udev create, first. And it will be implement each device types test later.

Change-Id: I86312d798503b1816c2826df35590031d1d2305a

haltests/meson.build [new file with mode: 0644]
haltests/test_hal_libinput.cpp [new file with mode: 0644]
haltests/test_hal_libinput.h [new file with mode: 0644]
haltests/test_main.cpp [new file with mode: 0644]
meson.build
packaging/libinput.spec

diff --git a/haltests/meson.build b/haltests/meson.build
new file mode 100644 (file)
index 0000000..dc8d74b
--- /dev/null
@@ -0,0 +1,23 @@
+deps_litest = [
+    dep_libinput,
+]
+
+libinput_haltests_srcs = [
+    'test_main.cpp',
+    'test_hal_libinput.cpp',
+]
+
+libinput_haltests_include_dirs = include_directories(
+    '.',
+)
+
+gmock_dep = dependency('gmock', method : 'pkg-config')
+
+executable(
+    'input-haltests',
+    libinput_haltests_srcs,
+    dependencies : [ deps_litest, gmock_dep ],
+    include_directories : [ libinput_haltests_include_dirs, includes_include, includes_src ],
+    install_dir : bindir_hal,
+    install : true
+)
diff --git a/haltests/test_hal_libinput.cpp b/haltests/test_hal_libinput.cpp
new file mode 100644 (file)
index 0000000..487ef87
--- /dev/null
@@ -0,0 +1,60 @@
+#include "test_hal_libinput.h"
+
+LibInputHalTest::~LibInputHalTest()
+{
+
+}
+
+static int open_restricted(const char *path, int flags, void *data)
+{
+       int fd;
+       fd = open(path, flags);
+       return fd < 0 ? -errno : fd;
+}
+static void close_restricted(int fd, void *data)
+{
+       close(fd);
+}
+
+static const struct libinput_interface simple_interface = {
+       .open_restricted = open_restricted,
+       .close_restricted = close_restricted,
+};
+
+TEST_F(LibInputHalTest, UdevCreateTest)
+{
+       struct libinput *li;
+       struct udev *udev_context;
+
+       udev_context = udev_new();
+       EXPECT_TRUE(udev_context != NULL);
+
+       li = libinput_udev_create_context(&simple_interface, NULL, udev_context);
+       EXPECT_TRUE(li != NULL);
+
+       libinput_udev_assign_seat(li, "seat0");
+       EXPECT_TRUE(li != NULL);
+
+       libinput_unref(li);
+       udev_unref(udev_context);
+}
+
+TEST_F(LibInputHalTest, GetDeviceListsTest)
+{
+       EXPECT_TRUE(true);
+}
+
+TEST_F(LibInputHalTest, MouseEventCheckTest)
+{
+       EXPECT_TRUE(true);
+}
+
+TEST_F(LibInputHalTest, KeyboardEventCheckTest)
+{
+       EXPECT_TRUE(true);
+}
+
+TEST_F(LibInputHalTest, TouchEventCheckTest)
+{
+       EXPECT_TRUE(true);
+}
diff --git a/haltests/test_hal_libinput.h b/haltests/test_hal_libinput.h
new file mode 100644 (file)
index 0000000..3f424b7
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef __LIBINPUT_TESTS_H__
+#define __LIBINPUT_TESTS_H__
+
+#include <errno.h>
+#include <fcntl.h>
+#include <libinput.h>
+#include <libudev.h>
+#include <libevdev/libevdev.h>
+#include <libevdev/libevdev-uinput.h>
+#include <unistd.h>
+#include <gtest/gtest.h>
+
+class LibInputHalTest : public ::testing::Test
+{
+       public:
+               LibInputHalTest() {};
+               virtual ~LibInputHalTest();
+};
+
+#endif // __LIBINPUT_TESTS_H__
diff --git a/haltests/test_main.cpp b/haltests/test_main.cpp
new file mode 100644 (file)
index 0000000..84f7f3f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Contact: DaYe Lee <dyamy.lee@samsung.com>
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+int main(int argc, char **argv)
+{
+       int ret = -1;
+
+       try{
+               testing::InitGoogleTest(&argc, argv);
+       } catch(...) {
+               std::cout << "Exception occurred" << std::endl;
+       }
+
+       try {
+               ret = RUN_ALL_TESTS();
+       } catch (const::testing::internal::GoogleTestFailureException& e) {
+               ret =-1;
+               std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+       }
+
+       return ret;
+}
+
index 438bb36..d8ce2a5 100644 (file)
@@ -1,7 +1,8 @@
-project('libinput', 'c',
+project('libinput',
+       ['c','cpp'],
        version : '1.22.0',
        license : 'MIT/Expat',
-       default_options : [ 'c_std=gnu99', 'warning_level=2' ],
+       default_options : [ 'c_std=gnu99', 'warning_level=2' , 'cpp_std=c++11'],
        meson_version : '>= 0.49.0')
 
 libinput_version = meson.project_version().split('.')
@@ -17,6 +18,7 @@ dir_src_quirks  = meson.current_source_dir() / 'quirks'
 dir_src_test    = meson.current_source_dir() / 'test'
 dir_src         = meson.current_source_dir() / 'src'
 dir_gitlab_ci  = meson.current_source_dir() / '.gitlab-ci'
+bindir_hal      = get_option('prefix') / get_option('bindir') / 'hal'
 
 dir_udev = get_option('udev-dir')
 if dir_udev == ''
@@ -1026,3 +1028,6 @@ configure_file(input : 'tools/libinput-quirks.man',
 
 ############ output files ############
 configure_file(output : 'config.h', configuration : config_h)
+
+############ hal tests ###############
+subdir('haltests')
index 091c75f..3fe6848 100644 (file)
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(libevent)
 BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(mtdev)
 BuildRequires:  pkgconfig(ttrace)
+BuildRequires:  pkgconfig(gmock)
 
 %global TZ_SYS_RO_SHARE  %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share}
 
@@ -46,6 +47,14 @@ processing and abstraction so minimize the amount of custom input
 code the user of libinput need to provide the common set of
 functionality that users expect.
 
+%package haltests
+Summary:    Input HAL Test Cases
+Requires:   %{name} = %{version}-%{release}
+
+%description haltests
+Input device HAL test cases
+
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -100,3 +109,8 @@ ninja -C builddir install
 %{_includedir}/*
 %{_libdir}/*.so
 %{_libdir}/pkgconfig/*
+
+%files haltests
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%{_bindir}/hal/input-haltests