From 87db96dcbc56516220d21fffccf5e88453fc848b Mon Sep 17 00:00:00 2001 From: "411148299@qq.com" <411148299@qq.com> Date: Tue, 19 Oct 2021 08:57:00 +0800 Subject: [PATCH] fix code style Signed-off-by: 411148299@qq.com <411148299@qq.com> --- .../test/unittest/param/client_unittest.cpp | 34 +++++++++-------- services/test/unittest/param/dac_unittest.cpp | 38 +++++++++---------- watchdog/linux/init_linux_watchdog.c | 2 +- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/services/test/unittest/param/client_unittest.cpp b/services/test/unittest/param/client_unittest.cpp index cef51c6b..9400b88a 100755 --- a/services/test/unittest/param/client_unittest.cpp +++ b/services/test/unittest/param/client_unittest.cpp @@ -188,6 +188,24 @@ static void TestCmd() RunParamCommand(ARRAY_LENGTH(argForSet9), const_cast(argForSet9)); } +void TestClientApi(char testBuffer[], uint32_t size, const char *name, const char *value) +{ + ParamHandle handle; + int ret = SystemFindParameter(name, &handle); + SystemSetParameter(name, value); + ret = SystemFindParameter(name, &handle); + EXPECT_EQ(ret, 0); + uint32_t commitId = 0; + ret = SystemGetParameterCommitId(handle, &commitId); + EXPECT_EQ(ret, 0); + ret = SystemGetParameterName(handle, testBuffer, size); + EXPECT_EQ(ret, 0); + EXPECT_EQ(strcmp(testBuffer, name), 0); + ret = SystemGetParameterValue(handle, testBuffer, &size); + EXPECT_EQ(ret, 0); + EXPECT_EQ(strcmp(testBuffer, value), 0); +} + void TestClient(int index) { char testBuffer[PARAM_BUFFER_SIZE] = { 0 }; @@ -213,21 +231,7 @@ void TestClient(int index) break; } case 2: { // 2 api test - ParamHandle handle; - uint32_t size = PARAM_BUFFER_SIZE; - int ret = SystemFindParameter(name.c_str(), &handle); - SystemSetParameter(name.c_str(), value.c_str()); - ret = SystemFindParameter(name.c_str(), &handle); - EXPECT_EQ(ret, 0); - uint32_t commitId = 0; - ret = SystemGetParameterCommitId(handle, &commitId); - EXPECT_EQ(ret, 0); - ret = SystemGetParameterName(handle, testBuffer, size); - EXPECT_EQ(ret, 0); - EXPECT_EQ(strcmp(testBuffer, name.c_str()), 0); - ret = SystemGetParameterValue(handle, testBuffer, &size); - EXPECT_EQ(ret, 0); - EXPECT_EQ(strcmp(testBuffer, value.c_str()), 0); + TestClientApi(testBuffer, PARAM_BUFFER_SIZE, name.c_str(), value.c_str()); break; } case 3: // 3 Traversal test diff --git a/services/test/unittest/param/dac_unittest.cpp b/services/test/unittest/param/dac_unittest.cpp index 9b72e8bc..1b841bc3 100755 --- a/services/test/unittest/param/dac_unittest.cpp +++ b/services/test/unittest/param/dac_unittest.cpp @@ -34,10 +34,10 @@ static int SecurityLabelGet(const ParamAuditData *auditData, void *context) return 0; } -class ParamDacTest : public ::testing::Test { +class DacUnitTest : public ::testing::Test { public: - ParamDacTest() {} - virtual ~ParamDacTest() {} + DacUnitTest() {} + virtual ~DacUnitTest() {} void SetUp() {} void TearDown() {} @@ -182,37 +182,37 @@ private: ParamSecurityOps clientParamSercurityOps; }; -HWTEST_F(ParamDacTest, TestDacGetLabel, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacGetLabel, TestSize.Level0) { - ParamDacTest test; + DacUnitTest test; test.TestDacGetLabel(); } -HWTEST_F(ParamDacTest, TestDacInitLocalLabel, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacInitLocalLabel, TestSize.Level0) { - ParamDacTest test; + DacUnitTest test; test.TestDacInitLocalLabel(); } -HWTEST_F(ParamDacTest, TestDacLabelEncode, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacLabelEncode, TestSize.Level0) { - ParamDacTest test; + DacUnitTest test; std::vector buffer; ParamSecurityLabel label = {0, { 4444, 5555}}; test.TestEncode(&label, buffer); test.TestDecode(&label, buffer); } -HWTEST_F(ParamDacTest, TestDacCheckFilePermission, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacCheckFilePermission, TestSize.Level0) { - ParamDacTest test; + DacUnitTest test; test.TestDacCheckFilePermission(PARAM_DEFAULT_PATH"/trigger_test.cfg"); } -HWTEST_F(ParamDacTest, TestDacCheckUserParaPermission, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacCheckUserParaPermission, TestSize.Level0) { // 相同用户 - ParamDacTest test; + DacUnitTest test; ParamDacData dacData; dacData.gid = getegid(); dacData.uid = geteuid(); @@ -250,10 +250,10 @@ HWTEST_F(ParamDacTest, TestDacCheckUserParaPermission, TestSize.Level0) EXPECT_EQ(ret, 0); } -HWTEST_F(ParamDacTest, TestDacCheckGroupParaPermission, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacCheckGroupParaPermission, TestSize.Level0) { // 相同组 - ParamDacTest test; + DacUnitTest test; ParamDacData dacData; dacData.gid = getegid(); dacData.uid = 13333; @@ -291,10 +291,10 @@ HWTEST_F(ParamDacTest, TestDacCheckGroupParaPermission, TestSize.Level0) EXPECT_EQ(ret, 0); } -HWTEST_F(ParamDacTest, TestDacCheckOtherParaPermission, TestSize.Level0) +HWTEST_F(DacUnitTest, TestDacCheckOtherParaPermission, TestSize.Level0) { // 其他用户 - ParamDacTest test; + DacUnitTest test; ParamDacData dacData; dacData.gid = 13333; dacData.uid = 13333; @@ -332,8 +332,8 @@ HWTEST_F(ParamDacTest, TestDacCheckOtherParaPermission, TestSize.Level0) EXPECT_EQ(ret, 0); } -HWTEST_F(ParamDacTest, TestClientDacCheckFilePermission, TestSize.Level0) +HWTEST_F(DacUnitTest, TestClientDacCheckFilePermission, TestSize.Level0) { - ParamDacTest test; + DacUnitTest test; test.TestClientDacCheckFilePermission(PARAM_DEFAULT_PATH"/trigger_test.cfg"); } diff --git a/watchdog/linux/init_linux_watchdog.c b/watchdog/linux/init_linux_watchdog.c index 58215242..7c73f315 100755 --- a/watchdog/linux/init_linux_watchdog.c +++ b/watchdog/linux/init_linux_watchdog.c @@ -62,7 +62,7 @@ int main(int argc, const char *argv[]) int gap = 0; if (argc >= 3) { // Argument nums greater than or equal to 3. - gap = atoi(argv[2]); // Second parameter. + gap = atoi(argv[2]); // 2 second parameter. } gap = gap > 0 ? gap : DEFAULT_GAP; -- GitLab