From 7f9b27be3fc997cc631dc6f0a98409a29bd326ec Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 20 Feb 2018 18:17:58 +0900 Subject: [PATCH] utests: not using setenv Change-Id: I734c97d423ddf0dc85068fea9cf3f7393d6ab681 --- utests/src/ut_tdm_buffer.cpp | 10 ++++------ utests/src/ut_tdm_capture.cpp | 12 ++++-------- utests/src/ut_tdm_client.cpp | 4 ++++ utests/src/ut_tdm_display.cpp | 15 +++++++-------- utests/src/ut_tdm_event_loop.cpp | 10 ++++------ utests/src/ut_tdm_helper.cpp | 8 ++++---- utests/src/ut_tdm_hwc_window.cpp | 16 ++++------------ utests/src/ut_tdm_layer.cpp | 35 +++++++++++------------------------ utests/src/ut_tdm_output.cpp | 17 +++++------------ utests/src/ut_tdm_pp.cpp | 12 ++++-------- utests/src/ut_tdm_vblank.cpp | 8 ++++++-- 11 files changed, 57 insertions(+), 90 deletions(-) diff --git a/utests/src/ut_tdm_buffer.cpp b/utests/src/ut_tdm_buffer.cpp index db5c4ca..6896547 100644 --- a/utests/src/ut_tdm_buffer.cpp +++ b/utests/src/ut_tdm_buffer.cpp @@ -4,6 +4,7 @@ extern "C" { #include "tdm.h" +#include "tdm_config.h" #include "tdm_backend.h" #include "tbm_bufmgr.h" #include "tbm_surface.h" @@ -23,18 +24,15 @@ protected: static void SetEnv(void) { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "0", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } static void UnsetEnv(void) { - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); - unsetenv("TDM_THREAD"); unsetenv("XDG_RUNTIME_DIR"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_capture.cpp b/utests/src/ut_tdm_capture.cpp index 068220a..4ebcc5a 100644 --- a/utests/src/ut_tdm_capture.cpp +++ b/utests/src/ut_tdm_capture.cpp @@ -31,6 +31,7 @@ #include "gtest/gtest.h" #include "ut_tdm.h" #include "tdm.h" +#include "tdm_config.h" extern "C" { #include "tbm_bufmgr.h" #include "tbm_drm_helper.h" @@ -50,21 +51,16 @@ protected: virtual void SetEnvs() { - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } virtual void UnsetEnvs() { - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_client.cpp b/utests/src/ut_tdm_client.cpp index adb71d5..1b65ed4 100644 --- a/utests/src/ut_tdm_client.cpp +++ b/utests/src/ut_tdm_client.cpp @@ -47,6 +47,7 @@ extern "C" { #include "tdm.h" +#include "tdm_config.h" #include "tdm_client.h" #include "tbm_surface.h" @@ -151,6 +152,9 @@ private: { setenv("XDG_RUNTIME_DIR", "/run", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } void unset_env_vars(void) diff --git a/utests/src/ut_tdm_display.cpp b/utests/src/ut_tdm_display.cpp index 2ba98ca..a80fb47 100644 --- a/utests/src/ut_tdm_display.cpp +++ b/utests/src/ut_tdm_display.cpp @@ -31,6 +31,7 @@ #include "gtest/gtest.h" extern "C" { #include "tdm.h" +#include "tdm_config.h" #include "tbm_bufmgr.h" #include "tbm_drm_helper.h" } @@ -40,10 +41,11 @@ protected: int master_fd = -42, tbm_fd = -42; void SetUp(void) { - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } void TearDown(void) { @@ -61,9 +63,7 @@ protected: exit(1); close(tbm_fd); } - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); unsetenv("TBM_DISPLAY_SERVER"); } }; @@ -75,10 +75,11 @@ protected: int master_fd = -42, tbm_fd = -42; void SetUp(void) { - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); tbm_bufmgr = tbm_bufmgr_init(-1); ASSERT_FALSE(tbm_bufmgr == NULL); tdm_error error = TDM_ERROR_NONE; @@ -108,9 +109,7 @@ protected: exit(1); close(tbm_fd); } - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); unsetenv("TBM_DISPLAY_SERVER"); } }; diff --git a/utests/src/ut_tdm_event_loop.cpp b/utests/src/ut_tdm_event_loop.cpp index b0dc4e7..e8ecaaa 100644 --- a/utests/src/ut_tdm_event_loop.cpp +++ b/utests/src/ut_tdm_event_loop.cpp @@ -5,6 +5,7 @@ extern "C" { #include "tdm.h" +#include "tdm_config.h" #include "tdm_backend.h" #include "tbm_bufmgr.h" #include "tbm_surface.h" @@ -22,18 +23,15 @@ protected: static void SetEnv(void) { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "0", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 0); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } static void UnsetEnv(void) { - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); - unsetenv("TDM_THREAD"); unsetenv("XDG_RUNTIME_DIR"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_helper.cpp b/utests/src/ut_tdm_helper.cpp index b9d8ba4..a093ffc 100644 --- a/utests/src/ut_tdm_helper.cpp +++ b/utests/src/ut_tdm_helper.cpp @@ -7,6 +7,7 @@ extern "C" { #include "tdm.h" +#include "tdm_config.h" #include "tdm_helper.h" #include "tdm_backend.h" #include "tbm_bufmgr.h" @@ -31,16 +32,15 @@ protected: tbm_surface_h surface; virtual void SetEnv() { - setenv("TDM_THREAD", "0", 1); - setenv("TDM_COMMIT_PER_VBLANK", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1); } void UnsetEnv() { - unsetenv("TDM_THREAD"); - unsetenv("TDM_COMMIT_PER_VBLANK"); unsetenv("XDG_RUNTIME_DIR"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_hwc_window.cpp b/utests/src/ut_tdm_hwc_window.cpp index 52ebc5b..aaa5d50 100644 --- a/utests/src/ut_tdm_hwc_window.cpp +++ b/utests/src/ut_tdm_hwc_window.cpp @@ -34,6 +34,7 @@ #include "stdint.h" #include "tdm.h" +#include "tdm_config.h" #include "tdm_backend.h" extern "C" { #include "tbm_bufmgr.h" @@ -52,27 +53,18 @@ protected: tdm_error error ; virtual void SetEnv() { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "1", 1); - setenv("TDM_COMMIT_PER_VBLANK", "1", 1); - setenv("TDM_DLOG", "1", 1); setenv("TDM_HWC", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1); } void UnsetEnv() { - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); - unsetenv("TDM_THREAD"); - unsetenv("TDM_COMMIT_PER_VBLANK"); - unsetenv("TDM_DLOG"); unsetenv("TDM_HWC"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_layer.cpp b/utests/src/ut_tdm_layer.cpp index 051c41f..dba3023 100644 --- a/utests/src/ut_tdm_layer.cpp +++ b/utests/src/ut_tdm_layer.cpp @@ -36,6 +36,8 @@ #include #include "tdm.h" +#include "tdm_config.h" + extern "C" { #include "tbm_bufmgr.h" #include "tbm_drm_helper.h" @@ -56,14 +58,11 @@ protected: bool has_layers = false; virtual void SetEnv() { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "0", 1); - setenv("TDM_COMMIT_PER_VBLANK", "1", 1); - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1); } void SetUp(void) { @@ -200,13 +199,7 @@ protected: close(tbm_fd); } - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); - unsetenv("TDM_THREAD"); - unsetenv("TDM_COMMIT_PER_VBLANK"); - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); unsetenv("TBM_DISPLAY_SERVER"); } @@ -359,14 +352,11 @@ class TDMLayerCommitThread : public TDMLayerCommit protected: void SetEnv() { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "1", 1); - setenv("TDM_COMMIT_PER_VBLANK", "1", 1); - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1); } }; @@ -375,14 +365,11 @@ class TDMLayerCommitWithDisabledCommitPerVblank : public TDMLayerCommit protected: void SetEnv() { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_THREAD", "0", 1); - setenv("TDM_COMMIT_PER_VBLANK", "0", 1); - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } }; diff --git a/utests/src/ut_tdm_output.cpp b/utests/src/ut_tdm_output.cpp index 0355065..db15445 100644 --- a/utests/src/ut_tdm_output.cpp +++ b/utests/src/ut_tdm_output.cpp @@ -32,6 +32,7 @@ #include "ut_tdm.h" #include #include "tdm.h" +#include "tdm_config.h" extern "C" { #include "tbm_bufmgr.h" #include "tbm_drm_helper.h" @@ -59,24 +60,17 @@ protected: } virtual void SetEnvs() { - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); - setenv("TDM_COMMIT_PER_VBLANK", "0", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } virtual void UnsetEnvs() { - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); unsetenv("TBM_DISPLAY_SERVER"); - unsetenv("TDM_COMMIT_PER_VBLANK"); } void SetUp(void) @@ -397,12 +391,11 @@ class TDMOutputCommitPerVblankEnabled : public TDMOutputCommit { { TDMOutputCommit::SetEnvs(); - setenv("TDM_COMMIT_PER_VBLANK", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1); } void UnsetEnvs(void) { TDMOutputCommit::UnsetEnvs(); - unsetenv("TDM_COMMIT_PER_VBLANK"); } }; diff --git a/utests/src/ut_tdm_pp.cpp b/utests/src/ut_tdm_pp.cpp index d420204..dd26f0e 100644 --- a/utests/src/ut_tdm_pp.cpp +++ b/utests/src/ut_tdm_pp.cpp @@ -31,6 +31,7 @@ #include "gtest/gtest.h" #include "ut_tdm.h" #include "tdm.h" +#include "tdm_config.h" extern "C" { #include "tbm_bufmgr.h" #include "tbm_drm_helper.h" @@ -53,21 +54,16 @@ protected: virtual void SetEnvs() { - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); - setenv("TDM_DEBUG_MODULE", "all", 1); - setenv("TDM_DEBUG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); } virtual void UnsetEnvs() { - unsetenv("TDM_DLOG"); unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DLOG"); - unsetenv("TDM_DEBUG_MODULE"); - unsetenv("TDM_DEBUG"); unsetenv("TBM_DISPLAY_SERVER"); } diff --git a/utests/src/ut_tdm_vblank.cpp b/utests/src/ut_tdm_vblank.cpp index 9eed3dc..a1cdc4d 100644 --- a/utests/src/ut_tdm_vblank.cpp +++ b/utests/src/ut_tdm_vblank.cpp @@ -30,6 +30,7 @@ #include "gtest/gtest.h" #include "tdm.h" +#include "tdm_config.h" #include "tbm_bufmgr.h" #include "ut_tdm.h" #include @@ -52,10 +53,13 @@ protected: tdm_output_conn_status status; tdm_error error = TDM_ERROR_NONE; - setenv("TDM_DLOG", "1", 1); setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DLOG", "1", 1); setenv("TBM_DISPLAY_SERVER", "1", 1); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 0); + tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0); + tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_LOG_LEVEL, 4); + tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "vblank,thread"); /* FIXME: fix the error. If we initialize TBM before TDM we get fail * in the tdm_output_set_dpms */ -- 2.7.4