From: INSUN PYO Date: Mon, 26 Oct 2020 08:04:18 +0000 (+0900) Subject: Add putenv test program X-Git-Tag: submit/tizen/20201117.064413~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d2a2d41dcd0abfe3d55dc84f0712f69348ae951;p=platform%2Fcore%2Fsystem%2Fsession-utils.git Add putenv test program Change-Id: I4765b24432eae3faf4b7ed36d1e6c8475838b85c --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 43df9ca..38d7177 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,3 +6,4 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) ADD_SUBDIRECTORY(src/dbus-activation-stop-test) ADD_SUBDIRECTORY(src/dbus-send-receive-test) ADD_SUBDIRECTORY(src/dbus-policy-two-wellknownname-per-one-connection-test) +ADD_SUBDIRECTORY(src/glibc-api-test) diff --git a/packaging/session-utils.spec b/packaging/session-utils.spec index 5a166ef..ed66203 100644 --- a/packaging/session-utils.spec +++ b/packaging/session-utils.spec @@ -48,6 +48,14 @@ Summary: dbus policy test for twe wellknownname per one connection. This package provides bus policy test for twe wellknownname per one connection. +############################################################################### +%package -n glibc-api-test +Summary: glibc api test programs + +%description -n glibc-api-test +This package provides glibc api test program + + ############################################################################### %prep %setup -q @@ -113,6 +121,12 @@ install -m 644 units/dbus-policy-two-wellknownname-per-one-connection-test-2.con %{_bindir}/dbus-policy-two-wellknownname-per-one-connection-test +############################################################################### +%files -n glibc-api-test +%license LICENSE.Apache-2.0 +%manifest session-utils.manifest +%{_bindir}/putenv-test + ############################################################################### %files -n g-debug-fatal-warnings %license LICENSE.Apache-2.0 diff --git a/src/glibc-api-test/CMakeLists.txt b/src/glibc-api-test/CMakeLists.txt new file mode 100644 index 0000000..29ed28b --- /dev/null +++ b/src/glibc-api-test/CMakeLists.txt @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(glibc-api-test C) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED +) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") + +ADD_EXECUTABLE(putenv-test putenv-test.c) +TARGET_LINK_LIBRARIES(putenv-test ${pkgs_LDFLAGS} -pie) + +INSTALL(TARGETS putenv-test DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/glibc-api-test/putenv-test.c b/src/glibc-api-test/putenv-test.c new file mode 100644 index 0000000..20cf0aa --- /dev/null +++ b/src/glibc-api-test/putenv-test.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 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 +#include +#include + +int main () +{ + char buf[] = "AAA=aaa"; + + printf ("putenv(%s) result = %d\n", buf, putenv(buf)); + + buf[4] = 'b'; + buf[5] = 'b'; + buf[6] = 'b'; + + printf("AAA=%s\n", getenv("AAA")); +}