Remove compilation using autotools
The intent behind this commit is build P-I-M with meson, so need to
remove files related to autotools.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I886726460fe46c69163d743cab5164d3774f2979
diff --git a/.gitignore b/.gitignore
index 44250a6..87fe930 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,43 +1,4 @@
-*.o
-*.lo
-*.la
-*.sw*
-phosphor-inventory
-generated.cpp
-gen_serialization.hpp
-test/gen_serialization.hpp
-xyz.openbmc_project.Example.*.cpp
-xyz/openbmc_project/Example/
-Makefile
-Makefile.in
-configure
-.deps
-.libs
-aclocal.m4
-ar-lib
-arm-openbmc-linux-gnueabi-libtool
-autom4te.cache/
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-depcomp
-install-sh
-ltmain.sh
-missing
-stamp-h1
-Makefile.extra
-extra_ifaces.cpp
-test-driver
-*.log
-*.trs
-*-libtool
-associations-test
-interface-ops-test
-manager-test
-serialize-test
-types-test
-utils-test
+build*/
+subprojects/*
+!subprojects/*.wrap
+
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 7d0e1d4..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,60 +0,0 @@
-BUILT_SOURCES=generated.cpp extra_ifaces.cpp gen_serialization.hpp
-
-CLEANFILES=$(BUILT_SOURCES)
-
-bin_PROGRAMS = phosphor-inventory
-noinst_LTLIBRARIES = libmanagercommon.la libmanager.la
-
-extra_yamldir=$(YAML_PATH)/extra_interfaces.d
-base_yamldir=$(YAML_PATH)
-
-phosphor_inventory_SOURCES = app.cpp
-phosphor_inventory_LDADD = libmanager.la $(SDBUSPLUS_LIBS)
-phosphor_inventory_CXXFLAGS = $(SDBUSPLUS_CFLAGS) -flto
-
-libmanagercommon_la_LDFLAGS = -static
-libmanagercommon_la_SOURCES = \
- errors.cpp \
- functor.cpp \
- manager.cpp
-
-if CREATE_INV_ASSOCIATIONS
-libmanagercommon_la_SOURCES += association_manager.cpp
-endif
-
-libmanagercommon_la_LIBADD = \
- $(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS) \
- -lstdc++fs
-libmanagercommon_la_CXXFLAGS = \
- $(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_DBUS_INTERACES_CFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
-
-libmanager_la_LDFLAGS = -static
-libmanager_la_SOURCES = \
- extra_ifaces.cpp \
- generated.cpp
-libmanager_la_LIBADD = \
- libmanagercommon.la \
- $(SDBUSPLUS_LIBS)
-
-clean-local: clean-extra
-
-if IFACES_PATH
-PIMGEN_ARGS=-i $(IFACES_PATH)
-endif
-
-generated.cpp:
- $(AM_V_GEN)$(PYTHON) $(top_srcdir)/pimgen.py $(PIMGEN_ARGS) -d \
- $(base_yamldir) -o $(builddir) -b $(BUSNAME) generate-cpp
-
-gen_serialization.hpp:
- $(AM_V_GEN)$(PYTHON) $(top_srcdir)/pimgen.py $(PIMGEN_ARGS) -d \
- $(base_yamldir) -o $(builddir) -b $(BUSNAME) \
- generate-serialization
-
-SUBDIRS = . test
-
--include Makefile.extra
diff --git a/Makefile.extra.in b/Makefile.extra.in
deleted file mode 100644
index 128a178..0000000
--- a/Makefile.extra.in
+++ /dev/null
@@ -1 +0,0 @@
-# Empty file so that 'configure' attempts to generate Makefile.extra.
diff --git a/bootstrap.sh b/bootstrap.sh
deleted file mode 100755
index 9fdf674..0000000
--- a/bootstrap.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \
- config.guess config.h.in config.sub configure depcomp install-sh \
- ltmain.sh missing *libtool test-driver"
-
-case $1 in
- clean)
- test -f Makefile && make maintainer-clean
- for file in ${AUTOCONF_FILES}; do
- find . -name "$file" -print0 | xargs -0 -r rm -rf
- done
- exit 0
- ;;
-esac
-
-autoreconf -i
-# shellcheck disable=SC2016
-echo 'Run "./configure ${CONFIGURE_FLAGS} && make"'
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 4946730..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,122 +0,0 @@
-# Initialization
-AC_PREREQ([2.69])
-AC_INIT([phosphor-inventory-manager], [1.0], [https://github.com/openbmc/phosphor-inventory-manager/issues])
-AC_LANG([C++])
-AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
-AM_SILENT_RULES([yes])
-
-# Checks for programs.
-AC_PROG_CXX
-AM_PROG_AR
-AC_PROG_INSTALL
-AC_PROG_MAKE_SET
-AC_PROG_AWK
-AC_CHECK_PROG([FIND], find, find)
-AC_CHECK_PROG([BASENAME], basename, basename)
-AC_CHECK_PROG([DIRNAME], dirname, dirname)
-AM_PATH_PYTHON([3],
- [AC_SUBST([PYTHON], [echo "$PYTHON"])],
- [AC_MSG_ERROR([Could not find python-3 installed...python-3 is required])])
-
-# Checks for libraries.
-PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
-PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
-PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
-PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AX_CXX_COMPILE_STDCXX([20],[noext])
-AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])
-
-# Checks for header files.
-AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])])
-AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...sdbusplus development package required])])
-
-# Checks for library functions.
-LT_INIT # Removes 'unrecognized options: --with-libtool-sysroot'
-
-# Make it possible for users to choose if they want test support
-# explicitly or not at all
-AC_ARG_ENABLE([tests], [Whether we should build test cases])
-
-# Check/set gtest specific functions.
-AS_IF([test "x$enable_tests" = "xyes"], [
- PKG_CHECK_MODULES([GMOCK], [gtest_main],,)
- PKG_CHECK_MODULES([GTEST], [gmock],,)
-])
-AX_PTHREAD
-
-AC_ARG_ENABLE([oe-sdk],
- AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
-)
-AC_ARG_VAR(OECORE_TARGET_SYSROOT,
- [Path to the OE SDK SYSROOT])
-AS_IF([test "x$enable_oe_sdk" == "xyes"],
- AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
- AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
- )
- AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
- [
- testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
- testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
- testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
- ]
- AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
-)
-
-AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
-AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
- AC_MSG_ERROR([Cannot find sdbus++]))
-
-AC_SUBST(BUSNAME, ["xyz.openbmc_project.Inventory.Manager"])
-AC_ARG_VAR(YAML_PATH, [The path to the yaml config files.])
-AC_ARG_VAR(IFACES_PATH, [The path to the interfaces PIM can create.])
-AS_IF([test "x$YAML_PATH" == "x"], [YAML_PATH="$srcdir/example"])
-AM_CONDITIONAL(IFACES_PATH, [test x"$IFACES_PATH" != "x"])
-
-AC_DEFINE_UNQUOTED([BUSNAME], ["$BUSNAME"], [The DBus busname to own.])
-AC_DEFINE_UNQUOTED([INVENTORY_ROOT], ["/xyz/openbmc_project/inventory"], [The DBus inventory namespace root.])
-AC_DEFINE_UNQUOTED([IFACE], ["xyz.openbmc_project.Inventory.Manager"], [The manager DBus interface.])
-
-AC_ARG_VAR(PIM_PERSIST_PATH, [Path of directory housing persisted inventory.])
-AS_IF([test "x$PIM_PERSIST_PATH" == "x"], \
- [PIM_PERSIST_PATH="/var/lib/phosphor-inventory-manager"])
-AC_DEFINE_UNQUOTED([PIM_PERSIST_PATH], ["$PIM_PERSIST_PATH"], \
- [Path of directory housing persisted inventory])
-
-AC_ARG_ENABLE([associations],
- AS_HELP_STRING([--enable-associations], [Enable creating D-Bus associations from a JSON definition.])
-)
-
-AC_ARG_VAR(CREATE_ASSOCIATIONS, [If associations should be created from a JSON definition.])
-
-AS_IF([test "x$enable_associations" == "xyes"],
- [CREATE_ASSOCIATIONS="yes"]
- AC_DEFINE_UNQUOTED([CREATE_ASSOCIATIONS], ["$CREATE_ASSOCIATIONS"],
- [If associations should be created from a JSON definition.])
- AC_CHECK_HEADER(nlohmann/json.hpp, ,
- [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
-)
-
-AM_CONDITIONAL([CREATE_INV_ASSOCIATIONS], [test "x$enable_associations" == "xyes"])
-
-AC_ARG_VAR(ASSOCIATIONS_FILE_PATH, [Path of associations JSON file.])
-AS_IF([test "x$ASSOCIATIONS_FILE_PATH" == "x"], \
- [ASSOCIATIONS_FILE_PATH="/usr/share/phosphor-inventory-manager/associations.json"])
-AC_DEFINE_UNQUOTED([ASSOCIATIONS_FILE_PATH], ["$ASSOCIATIONS_FILE_PATH"], \
- [Path of associations JSON file])
-
-AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
-AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=2])
-AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])
-
-# Create configured output
-AC_CONFIG_FILES([Makefile.extra],
- [${srcdir}/generate_makefile.sh $yaml > Makefile.extra],
- [yaml=${YAML_PATH}/extra_interfaces.d])
-AC_CONFIG_FILES([test/Makefile.extra],
- [${srcdir}/generate_makefile.sh $test_yaml > test/Makefile.extra],
- [test_yaml=$srcdir/example/extra_interfaces.d])
-AC_CONFIG_FILES([Makefile test/Makefile])
-AC_OUTPUT
diff --git a/example/events.d/README.md b/example/events.d/README.md
deleted file mode 100644
index 336b876..0000000
--- a/example/events.d/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-The files in this directory serve as an illustration of supported
-PIM features and also enable the test suite.
-
-The placement of an event into a file is arbitrary. Multiple files
-are used only to validate that the PIM code generator can handle
-this appropriately.
diff --git a/example/events.d/match1.yaml b/example/events.d/match1.yaml
deleted file mode 100644
index 6246dbd..0000000
--- a/example/events.d/match1.yaml
+++ /dev/null
@@ -1,140 +0,0 @@
-description: >
- The sample events below serve to illustrate PIM features
- and are also used by the PIM test suite.
-
-events:
- - name: setProperty + propertyChangedTo example
- description: >
- Sets the value of ExampleProperty1 on /changeme
- when the value of ExampleProperty2 on
- /testing/trigger2 changes to yyyxxx.
- type: match
- signatures:
- - type: signal
- interface: org.freedesktop.DBus.Properties
- path: /testing/trigger2
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty2
- value:
- type: string
- value: yyyxxx
- actions:
- - name: setProperty
- interface: xyz.openbmc_project.Example.Iface1
- property: ExampleProperty1
- paths:
- - /changeme
- value:
- type: string
- value: changed
-
- - name: createObjects + propertyChangedTo example
- description: >
- Create /createme1 and /createme2 when the value of
- ExampleProperty2 on /testing/trigger5 changes to abc123.
- type: match
- signatures:
- - type: signal
- interface: org.freedesktop.DBus.Properties
- path: /testing/trigger5
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty2
- value:
- type: string
- value: abc123
- actions:
- - name: createObjects
- objs:
- /createme1:
- xyz.openbmc_project.Example.Iface1:
- ExampleProperty1:
- value: foo
- type: string
- xyz.openbmc_project.Example.Iface2:
- ExampleProperty2:
- value: bar
- type: string
- ExampleProperty3:
- value: 999
- type: int64
- /createme2:
- xyz.openbmc_project.Example.Iface1:
- ExampleProperty1:
- value: bar
- type: string
- xyz.openbmc_project.Example.Iface2:
- ExampleProperty2:
- value: foo
- type: string
- ExampleProperty3:
- value: 888
- type: int64
-
- - name: startup event example
- description: >
- Create /createme3 at startup if ExampleProperty1 on /changeme
- equals changed.
- type: startup
- filters:
- - name: propertyIs
- path: /changeme
- interface: xyz.openbmc_project.Example.Iface1
- property: ExampleProperty1
- value:
- value: changed
- type: string
- dbusMember: "sdbusplus::xyz::openbmc_project::Example::\
- server::Iface1"
- actions:
- - name: createObjects
- objs:
- /createme3:
- xyz.openbmc_project.Example.Iface1:
- ExampleProperty1:
- value: foo
- type: string
-
- - name: conditional setProperty example
- description: >
- Sets the ExampleProperty1 on the /changeme object when
- the value of ExampleProperty3 on /testing/trigger7
- changes to 10 and the value of the ExampleProperty3
- value on /changeme is 22.
- type: match
- signatures:
- - type: signal
- path: /testing/trigger7
- interface: org.freedesktop.DBus.Properties
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- value:
- value: 10
- type: int64
- actions:
- - name: setProperty
- interface: xyz.openbmc_project.Example.Iface1
- property: ExampleProperty1
- paths:
- - /changeme
- value:
- type: string
- value: changed
- conditions:
- - name: propertyIs
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- value:
- value: 22
- type: int64
-
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/example/events.d/match2.yaml b/example/events.d/match2.yaml
deleted file mode 100644
index 6fbe496..0000000
--- a/example/events.d/match2.yaml
+++ /dev/null
@@ -1,121 +0,0 @@
-description: >
- The sample events below serve to illustrate PIM features
- and are also used by the PIM test suite.
-
-events:
- - name: destroyObject + propertyChangedTo example
- description: >
- Destroys the /deleteme1 and /deleteme2 objects
- When the value of ExampleProperty2 on
- /testing/trigger1 changes to xxxyyy.
- type: match
- signatures:
- - type: signal
- path: /testing/trigger1
- interface: org.freedesktop.DBus.Properties
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty2
- value:
- type: string
- value: xxxyyy
- actions:
- - name: destroyObjects
- paths:
- - /deleteme1
- - /deleteme2
-
- - name: destroyObject + propertyChangedTo<int64> example
- description: >
- Destroys the /deleteme3 object when the value of
- ExampleProperty3 on /testing/trigger3
- changes to 10.
- type: match
- signatures:
- - type: signal
- path: /testing/trigger3
- interface: org.freedesktop.DBus.Properties
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- value:
- value: 10
- type: int64
- actions:
- - name: destroyObjects
- paths:
- - /deleteme3
-
- - name: propertyIs example
- description: >
- Destroys the /deleteme3 object when the value of
- ExampleProperty3 on /testing/trigger4 is 99
- and the value of ExampleProperty2 on /testing/trigger4
- changes to "123".
- type: match
- signatures:
- - type: signal
- path: /testing/trigger4
- interface: org.freedesktop.DBus.Properties
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty2
- value:
- value: 123
- type: string
- - name: propertyIs
- path: /testing/trigger4
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- service: phosphor.inventory.test.example
- value:
- value: 99
- type: int64
- actions:
- - name: destroyObjects
- paths:
- - /deleteme3
-
- - name: conditional destroyObject example
- description: >
- Destroys the /deleteme3 object when the value of
- ExampleProperty3 on /testing/trigger6
- changes to 10 and the value of the ExampleProperty3
- value on /deleteme3 is 22.
- Destroys the /deleteme4 object when the value of
- ExampleProperty3 on /testing/trigger6
- changes to 10 and the value of the ExampleProperty3
- value on /deleteme4 is 22.
- type: match
- signatures:
- - type: signal
- path: /testing/trigger6
- interface: org.freedesktop.DBus.Properties
- member: PropertiesChanged
- filters:
- - name: propertyChangedTo
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- value:
- value: 10
- type: int64
- actions:
- - name: destroyObjects
- paths:
- - /deleteme3
- - /deleteme4
- conditions:
- - name: propertyIs
- interface: xyz.openbmc_project.Example.Iface2
- property: ExampleProperty3
- value:
- value: 22
- type: int64
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface1.interface.yaml b/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface1.interface.yaml
deleted file mode 100644
index 1333fa9..0000000
--- a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface1.interface.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-description: >
- Example interface for PIM.
-properties:
- - name: ExampleProperty1
- type: string
- description: >
- An example property.
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml b/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml
deleted file mode 100644
index 88034d7..0000000
--- a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-description: >
- Example interface for PIM.
-properties:
- - name: ExampleProperty2
- type: string
- description: >
- An example string property.
- - name: ExampleProperty3
- type: int64
- description: >
- An example int64 property.
- - name: Example_Property4
- type: int64
- description: >
- An example int64 property with an underscore in the name.
- - name: ExampleProperty5
- type: array[struct[string, string, string]]
- description: >
- An example array property.
-
-
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface3.interface.yaml b/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface3.interface.yaml
deleted file mode 100644
index 6a76b8a..0000000
--- a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface3.interface.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-description: >
- Example empty interface for PIM.
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/generate_makefile.sh b/generate_makefile.sh
deleted file mode 100755
index fce93e7..0000000
--- a/generate_makefile.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-yaml_top=$1
-toplevel_dirs=xyz
-interfaces=
-
-if [ -d "$yaml_top/$toplevel_dirs" ]; then
- cd "$yaml_top" || exit 1
- interfaces=$(find $toplevel_dirs -name "*.interface.yaml")
-fi
-
-for i in ${interfaces};
-do
- iface_path="$(dirname "$i")/$(basename "$i" .interface.yaml)"
- iface="$(echo "$iface_path" | sed 's/\//./g')"
- cat <<MAKEFILE
-${i%.interface.yaml}/server.cpp: \$(extra_yamldir)/${i} ${i%.interface.yaml}/server.hpp
- @mkdir -p \`dirname \$@\`
- \$(AM_V_GEN)\$(SDBUSPLUSPLUS) -r \$(extra_yamldir) interface server-cpp ${iface} > \$@
-
-${i%.interface.yaml}/server.hpp: \$(extra_yamldir)/${i}
- @mkdir -p \`dirname \$@\`
- \$(AM_V_GEN)\$(SDBUSPLUSPLUS) -r \$(extra_yamldir) interface server-header ${iface} > \$@
-
-MAKEFILE
-
-done
-
-echo "extra_ifaces_cpp_SOURCES = \\"
-for i in ${interfaces};
-do
- echo " ${i%.interface.yaml}/server.cpp \\"
-done
-echo
-
-echo "extra_ifaces_hpp_SOURCES = \\"
-for i in ${interfaces};
-do
- echo " ${i%.interface.yaml}/server.hpp \\"
-done
-echo
-
-echo "extra_ifaces.cpp: \$(extra_ifaces_cpp_SOURCES)"
-if [ "$interfaces" ]; then
- echo " \$(AM_V_GEN)cat \$^ > \$@"
-else
- echo " \$(AM_V_GEN)touch \$@"
-fi
-
-cat << MAKEFILE
-
-.PHONY: clean-extra
-clean-extra:
- for i in \$(extra_ifaces_cpp_SOURCES) \\
- \$(extra_ifaces_hpp_SOURCES); \\
- do \\
- test -e \$\$i && rm \$\$i ; \\
- test -d \`dirname \$\$i\` && rmdir -p \`dirname \$\$i\` ; \\
- true; \\
- done
-MAKEFILE
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index a53747b..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,81 +0,0 @@
-BUILT_SOURCES=generated.cpp extra_ifaces.cpp gen_serialization.hpp
-CLEANFILES=$(BUILT_SOURCES)
-
-AM_CPPFLAGS = -iquote$(top_srcdir)
-
-check_PROGRAMS =
-noinst_PROGRAMS = phosphor-inventory-test
-noinst_LTLIBRARIES = libtest.la
-
-TESTS = ${check_PROGRAMS}
-
-types_test_SOURCES = types_test.cpp
-types_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-types_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS}
-types_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += types-test
-
-utils_test_SOURCES = utils_test.cpp
-utils_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-utils_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS}
-utils_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += utils-test
-
-serialize_test_SOURCES = serialize_test.cpp
-serialize_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-serialize_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS} -lstdc++fs
-serialize_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += serialize-test
-
-interface_ops_test_SOURCES = interface_ops_test.cpp
-interface_ops_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-interface_ops_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS}
-interface_ops_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += interface-ops-test
-
-manager_test_SOURCES = manager_test.cpp
-manager_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-manager_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS}
-manager_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += manager-test
-
-associations_test_SOURCES = associations_test.cpp
-associations_test_CFLAGS = \
- ${GTEST_CFLAGS} ${GMOCK_CFLAGS} $(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_DBUS_INTERACES_CFLAGS)
-associations_test_LDADD = \
- ${GTEST_LIBS} ${GMOCK_LIBS} ${SDBUSPLUS_LIBS} -lstdc++fs \
- $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
- $(top_builddir)/association_manager.o
-
-associations_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
-check_PROGRAMS += associations-test
-
-extra_yamldir=$(top_srcdir)/example/extra_interfaces.d
-
-phosphor_inventory_test_SOURCES = test.cpp
-phosphor_inventory_test_LDADD = \
- libtest.la
- $(SDBSUPLUS_LIBS) \
- $(PTHREAD_LIBS)
-phosphor_inventory_test_CXXFLAGS = \
- $(SDBUSPLUS_CFLAGS) \
- $(PTHREAD_CFLAGS)
-
-libtest_la_LDFLAGS = -static
-libtest_la_SOURCES = \
- extra_ifaces.cpp \
- generated.cpp
-libtest_la_LIBADD = \
- $(top_builddir)/libmanagercommon.la \
- $(SDBUSPLUS_LIBS)
-
-clean-local: clean-extra
-
-generated.cpp:
- $(AM_V_GEN)$(PYTHON) $(top_srcdir)/pimgen.py -d $(extra_yamldir)/.. -o $(builddir) generate-cpp
-
-gen_serialization.hpp:
- $(AM_V_GEN)$(PYTHON) $(top_srcdir)/pimgen.py -d $(extra_yamldir)/.. -o $(builddir) generate-serialization
-
--include Makefile.extra
diff --git a/test/Makefile.extra.in b/test/Makefile.extra.in
deleted file mode 100644
index 128a178..0000000
--- a/test/Makefile.extra.in
+++ /dev/null
@@ -1 +0,0 @@
-# Empty file so that 'configure' attempts to generate Makefile.extra.
diff --git a/test/test.cpp b/test/test.cpp
deleted file mode 100644
index 5d020e9..0000000
--- a/test/test.cpp
+++ /dev/null
@@ -1,497 +0,0 @@
-/**
- * Copyright © 2016 IBM Corporation
- *
- * 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 "config.h"
-
-#include "manager.hpp"
-#include "xyz/openbmc_project/Example/Iface1/server.hpp"
-#include "xyz/openbmc_project/Example/Iface2/server.hpp"
-
-#include <algorithm>
-#include <cassert>
-#include <chrono>
-#include <iostream>
-#include <thread>
-
-using namespace std::literals::chrono_literals;
-using namespace std::literals::string_literals;
-
-using Object = phosphor::inventory::manager::Object;
-using ObjectMap = std::map<sdbusplus::message::object_path, Object>;
-
-constexpr auto MGR_SERVICE = "phosphor.inventory.test.mgr";
-constexpr auto MGR_INTERFACE = IFACE;
-constexpr auto MGR_ROOT = "/testing/inventory";
-constexpr auto EXAMPLE_SERVICE = "phosphor.inventory.test.example";
-constexpr auto EXAMPLE_ROOT = "/testing";
-
-const auto trigger1 =
- sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger1"s);
-const auto trigger2 =
- sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger2"s);
-const auto trigger3 =
- sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger3"s);
-const auto trigger4 =
- sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger4"s);
-const auto trigger5 =
- sdbusplus::message::object_path(EXAMPLE_ROOT + "/trigger5"s);
-
-const sdbusplus::message::object_path relDeleteMeOne{"/deleteme1"};
-const sdbusplus::message::object_path relDeleteMeTwo{"/deleteme2"};
-const sdbusplus::message::object_path relDeleteMeThree{"/deleteme3"};
-
-const std::string root{MGR_ROOT};
-const std::string deleteMeOne{root + relDeleteMeOne.str};
-const std::string deleteMeTwo{root + relDeleteMeTwo.str};
-const std::string deleteMeThree{root + relDeleteMeThree.str};
-
-using ExampleIface1 = sdbusplus::xyz::openbmc_project::Example::server::Iface1;
-using ExampleIface2 = sdbusplus::xyz::openbmc_project::Example::server::Iface2;
-
-/** @class ExampleService
- * @brief Host an object for triggering events.
- */
-struct ExampleService
-{
- ~ExampleService() = default;
- ExampleService() :
- shutdown(false), bus(sdbusplus::bus::new_default()),
- objmgr(sdbusplus::server::manager::manager(bus, MGR_ROOT))
- {
- bus.request_name(EXAMPLE_SERVICE);
- }
-
- void run()
- {
- sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t1(
- bus, trigger1.str.c_str());
- sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t2(
- bus, trigger2.str.c_str());
- sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t3(
- bus, trigger3.str.c_str());
- sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t4(
- bus, trigger4.str.c_str());
- sdbusplus::server::object::object<ExampleIface1, ExampleIface2> t5(
- bus, trigger5.str.c_str());
-
- while (!shutdown)
- {
- bus.process_discard();
- bus.wait((5000000us).count());
- }
- }
-
- volatile bool shutdown;
- sdbusplus::bus::bus bus;
- sdbusplus::server::manager::manager objmgr;
-};
-
-/** @class SignalQueue
- * @brief Store DBus signals in a queue.
- */
-class SignalQueue
-{
- public:
- ~SignalQueue() = default;
- SignalQueue() = delete;
- SignalQueue(const SignalQueue&) = delete;
- SignalQueue(SignalQueue&&) = default;
- SignalQueue& operator=(const SignalQueue&) = delete;
- SignalQueue& operator=(SignalQueue&&) = default;
- explicit SignalQueue(const std::string& match) :
- _bus(sdbusplus::bus::new_default()),
- _match(_bus, match.c_str(), &callback, this), _next(nullptr)
- {}
-
- auto&& pop(unsigned timeout = 1000000)
- {
- while (timeout > 0 && !_next)
- {
- _bus.process_discard();
- _bus.wait(50000);
- timeout -= 50000;
- }
- return std::move(_next);
- }
-
- private:
- static int callback(sd_bus_message* m, void* context, sd_bus_error*)
- {
- auto* me = static_cast<SignalQueue*>(context);
- sd_bus_message_ref(m);
- sdbusplus::message::message msg{m};
- me->_next = std::move(msg);
- return 0;
- }
-
- sdbusplus::bus::bus _bus;
- sdbusplus::bus::match_t _match;
- sdbusplus::message::message _next;
-};
-
-/**@brief Find a subset of interfaces and properties in an object. */
-auto hasProperties(const Object& l, const Object& r)
-{
- Object result;
- std::set_difference(r.cbegin(), r.cend(), l.cbegin(), l.cend(),
- std::inserter(result, result.end()));
- return result.empty();
-}
-
-/**@brief Check an object for one or more interfaces. */
-auto hasInterfaces(const std::vector<std::string>& l, const Object& r)
-{
- std::vector<std::string> stripped, interfaces;
- std::transform(r.cbegin(), r.cend(), std::back_inserter(stripped),
- [](auto& p) { return p.first; });
- std::set_difference(stripped.cbegin(), stripped.cend(), l.cbegin(),
- l.cend(), std::back_inserter(interfaces));
- return interfaces.empty();
-}
-
-void runTests()
-{
- const std::string exampleRoot{EXAMPLE_ROOT};
- auto b = sdbusplus::bus::new_default();
-
- auto notify = [&]() {
- return b.new_method_call(MGR_SERVICE, MGR_ROOT, MGR_INTERFACE,
- "Notify");
- };
- auto set = [&](const std::string& path) {
- return b.new_method_call(EXAMPLE_SERVICE, path.c_str(),
- "org.freedesktop.DBus.Properties", "Set");
- };
-
- Object obj{
- {"xyz.openbmc_project.Example.Iface1",
- {{"ExampleProperty1", "test1"s}}},
- {"xyz.openbmc_project.Example.Iface2",
- {{"ExampleProperty2", "test2"s},
- {"ExampleProperty3", static_cast<int64_t>(0ll)}}},
- };
-
- // Validate startup events occurred.
- {
- sdbusplus::message::object_path relCreateMe3{"/createme3"};
- std::string createMe3{root + relCreateMe3.str};
-
- auto get =
- b.new_method_call(MGR_SERVICE, createMe3.c_str(),
- "org.freedesktop.DBus.Properties", "GetAll");
- get.append("xyz.openbmc_project.Example.Iface1");
- auto resp = b.call(get);
-
- Object::mapped_type properties;
- assert(!resp.is_method_error());
- resp.read(properties);
- }
-
- // Make sure the notify method works.
- {
- sdbusplus::message::object_path relPath{"/foo"};
- std::string path(root + relPath.str);
-
- SignalQueue queue("path='" + root + "',member='InterfacesAdded'");
-
- auto m = notify();
- m.append(ObjectMap({{relPath, obj}}));
- b.call(m);
-
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sdbusplus::message::object_path signalPath;
- Object signalObjectType;
- sig.read(signalPath);
- assert(path == signalPath.str);
- sig.read(signalObjectType);
- assert(hasProperties(signalObjectType, obj));
- auto moreSignals{queue.pop()};
- assert(!moreSignals);
- }
-
- // Validate the propertyIs filter.
- {// Create an object to be deleted.
- {auto m = notify();
- m.append(ObjectMap({{relDeleteMeThree, obj}}));
- b.call(m);
-}
-
-// Validate that the action does not run if the property doesn't match.
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("123"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
-}
-
-// Validate that the action does run if the property matches.
-{
- // Set ExampleProperty2 to something else to the 123 filter
- // matches.
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("xyz"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
-}
-{
- // Set ExampleProperty3 to 99.
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(std::variant<int64_t>(99));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
-}
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger4.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("123"));
- b.call(m);
-
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeThree);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
-}
-}
-
-// Make sure DBus signals are handled.
-{// Create some objects to be deleted by an action.
- {auto m = notify();
-m.append(ObjectMap({{relDeleteMeOne, obj}}));
-b.call(m);
-}
-{
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeTwo, obj}}));
- b.call(m);
-}
-{
- auto m = notify();
- m.append(ObjectMap({{relDeleteMeThree, obj}}));
- b.call(m);
-}
-
-// Set some properties that should not trigger due to a filter.
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger1.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("abc123"));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
-}
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
- auto m = set(trigger3.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(std::variant<int64_t>(11));
- b.call(m);
- auto sig{queue.pop()};
- assert(!sig);
-}
-
-// Set some properties that should trigger.
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
-
- auto m = set(trigger1.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("xxxyyy"));
- b.call(m);
-
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeOne);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeTwo);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- // Make sure there were only two signals.
- auto sig{queue.pop()};
- assert(!sig);
- }
-}
-{
- SignalQueue queue("path='" + root + "',member='InterfacesRemoved'");
-
- auto m = set(trigger3.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty3");
- m.append(std::variant<int64_t>(10));
- b.call(m);
-
- sdbusplus::message::object_path sigpath;
- std::vector<std::string> interfaces;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(sigpath);
- assert(sigpath == deleteMeThree);
- sig.read(interfaces);
- std::sort(interfaces.begin(), interfaces.end());
- assert(hasInterfaces(interfaces, obj));
- }
- {
- // Make sure there was only one signal.
- auto sig{queue.pop()};
- assert(!sig);
- }
-}
-}
-
-// Validate the set property action.
-{
- sdbusplus::message::object_path relChangeMe{"/changeme"};
- std::string changeMe{root + relChangeMe.str};
-
- // Create an object to be updated by the set property action.
- {
- auto m = notify();
- m.append(ObjectMap({{relChangeMe, obj}}));
- b.call(m);
- }
-
- // Trigger and validate the change.
- {
- SignalQueue queue("path='" + changeMe + "',member='PropertiesChanged'");
- auto m = set(trigger2.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("yyyxxx"));
- b.call(m);
-
- std::string sigInterface;
- std::map<std::string, std::variant<std::string>> sigProperties;
- {
- std::vector<std::string> interfaces;
- auto sig{queue.pop()};
- sig.read(sigInterface);
- assert(sigInterface == "xyz.openbmc_project.Example.Iface1");
- sig.read(sigProperties);
- assert(std::get<std::string>(sigProperties["ExampleProperty1"]) ==
- "changed");
- }
- }
-}
-
-// Validate the create object action.
-{
- sdbusplus::message::object_path relCreateMe1{"/createme1"};
- sdbusplus::message::object_path relCreateMe2{"/createme2"};
- std::string createMe1{root + relCreateMe1.str};
- std::string createMe2{root + relCreateMe2.str};
-
- // Trigger the action.
- {
- sdbusplus::message::object_path signalPath;
- Object signalObject;
-
- SignalQueue queue("path='" + root + "',member='InterfacesAdded'");
-
- auto m = set(trigger5.str);
- m.append("xyz.openbmc_project.Example.Iface2");
- m.append("ExampleProperty2");
- m.append(std::variant<std::string>("abc123"));
- b.call(m);
- {
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(signalPath);
- assert(createMe1 == signalPath.str);
- sig.read(signalObject);
- }
- {
- auto sig{queue.pop()};
- assert(static_cast<bool>(sig));
- sig.read(signalPath);
- assert(createMe2 == signalPath.str);
- sig.read(signalObject);
- }
-
- auto moreSignals{queue.pop()};
- assert(!moreSignals);
- }
-}
-}
-
-int main()
-{
- phosphor::inventory::manager::Manager mgr(sdbusplus::bus::new_default(),
- MGR_ROOT);
- ExampleService d;
-
- auto f1 = [](auto mgr) { mgr->run(MGR_SERVICE); };
- auto f2 = [](auto d) { d->run(); };
-
- auto t1 = std::thread(f1, &mgr);
- auto t2 = std::thread(f2, &d);
-
- runTests();
-
- mgr.shutdown();
- d.shutdown = true;
-
- // Wait for server threads to exit.
- t1.join();
- t2.join();
- std::cout << "Success! Waiting for threads to exit..." << std::endl;
-
- return 0;
-}
-
-// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4