From 55bcb933eee753a0cdd13f9861a00c33d194c1e7 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 17 Jun 2022 11:17:52 -0400 Subject: [PATCH] Move protocol module from common to command. This module has dependencies on command/command so it does not make sense for it to be in the common module. Also move protocolFree() to main() since this is a very large dependency. Adjust the tests so command/exit can be tested later. This is a bit messy but will get adjusted as we improve the test harness. --- src/Makefile.in | 2 +- src/{common => command}/exit.c | 5 +- src/{common => command}/exit.h | 5 +- src/command/server/server.c | 2 +- src/main.c | 5 +- src/meson.build | 2 +- test/code-count/file-type.yaml | 24 +++--- test/define.yaml | 76 +++++++++---------- .../src/module/{common => command}/exitTest.c | 4 +- test/src/module/command/serverTest.c | 2 +- 10 files changed, 64 insertions(+), 63 deletions(-) rename src/{common => command}/exit.c (98%) rename src/{common => command}/exit.h (94%) rename test/src/module/{common => command}/exitTest.c (97%) diff --git a/src/Makefile.in b/src/Makefile.in index 689962de6..fdd267b82 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -64,6 +64,7 @@ SRCS = \ command/check/check.c \ command/check/common.c \ command/expire/expire.c \ + command/exit.c \ command/help/help.c \ command/info/info.c \ command/command.c \ @@ -105,7 +106,6 @@ SRCS = \ common/crypto/common.c \ common/crypto/hash.c \ common/exec.c \ - common/exit.c \ common/fork.c \ common/ini.c \ common/io/client.c \ diff --git a/src/common/exit.c b/src/command/exit.c similarity index 98% rename from src/common/exit.c rename to src/command/exit.c index d5542b757..995f679b7 100644 --- a/src/common/exit.c +++ b/src/command/exit.c @@ -7,9 +7,9 @@ Exit Routines #include #include "command/command.h" +#include "command/exit.h" #include "common/debug.h" #include "common/error.h" -#include "common/exit.h" #include "common/lock.h" #include "common/log.h" #include "config/config.h" @@ -138,9 +138,6 @@ exitSafe(int result, bool error, SignalType signalType) result = errorCode(); } - // Free protocol objects - protocolFree(); - // Log command end if a command is set if (cfgCommand() != cfgCmdNone) { diff --git a/src/common/exit.h b/src/command/exit.h similarity index 94% rename from src/common/exit.h rename to src/command/exit.h index 6dcdc71db..a975f3ac0 100644 --- a/src/common/exit.h +++ b/src/command/exit.h @@ -1,9 +1,10 @@ /*********************************************************************************************************************************** Exit Routines ***********************************************************************************************************************************/ -#ifndef COMMON_EXIT_H -#define COMMON_EXIT_H +#ifndef COMMAND_EXIT_H +#define COMMAND_EXIT_H +#include #include /*********************************************************************************************************************************** diff --git a/src/command/server/server.c b/src/command/server/server.c index 5ff236033..76e787bb1 100644 --- a/src/command/server/server.c +++ b/src/command/server/server.c @@ -5,10 +5,10 @@ Server Command #include +#include "command/exit.h" #include "command/remote/remote.h" #include "command/server/server.h" #include "common/debug.h" -#include "common/exit.h" #include "common/fork.h" #include "common/io/socket/server.h" #include "common/io/tls/server.h" diff --git a/src/main.c b/src/main.c index dc1cb053c..d554cb1db 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,7 @@ Main #include "command/command.h" #include "command/control/start.h" #include "command/control/stop.h" +#include "command/exit.h" #include "command/expire/expire.h" #include "command/help/help.h" #include "command/info/info.h" @@ -33,7 +34,6 @@ Main #include "command/verify/verify.h" #include "common/debug.h" #include "common/error.h" -#include "common/exit.h" #include "common/io/fdRead.h" #include "common/io/fdWrite.h" #include "common/stat.h" @@ -306,5 +306,8 @@ main(int argListSize, const char *argList[]) } TRY_END(); + // Free protocol objects + protocolFree(); + FUNCTION_LOG_RETURN(INT, error ? result : exitSafe(result, false, 0)); } diff --git a/src/meson.build b/src/meson.build index 1a559908c..989eb03d8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -184,6 +184,7 @@ src_pgbackrest = [ 'command/backup/file.c', 'command/check/check.c', 'command/check/common.c', + 'command/exit.c', 'command/expire/expire.c', 'command/help/help.c', 'command/info/info.c', @@ -228,7 +229,6 @@ src_pgbackrest = [ 'common/crypto/common.c', 'common/crypto/hash.c', 'common/exec.c', - 'common/exit.c', 'common/fork.c', 'common/ini.c', 'common/io/client.c', diff --git a/test/code-count/file-type.yaml b/test/code-count/file-type.yaml index 8bb3bbd4a..84dd6234c 100644 --- a/test/code-count/file-type.yaml +++ b/test/code-count/file-type.yaml @@ -439,6 +439,14 @@ src/command/control/stop.h: class: core type: c/h +src/command/exit.c: + class: core + type: c + +src/command/exit.h: + class: core + type: c/h + src/command/expire/expire.c: class: core type: c @@ -807,14 +815,6 @@ src/common/exec.h: class: core type: c/h -src/common/exit.c: - class: core - type: c - -src/common/exit.h: - class: core - type: c/h - src/common/fork.c: class: core type: c @@ -2179,6 +2179,10 @@ test/src/module/command/controlTest.c: class: test/module type: c +test/src/module/command/exitTest.c: + class: test/module + type: c + test/src/module/command/expireTest.c: class: test/module type: c @@ -2255,10 +2259,6 @@ test/src/module/common/execTest.c: class: test/module type: c -test/src/module/common/exitTest.c: - class: test/module - type: c - test/src/module/common/forkTest.c: class: test/module type: c diff --git a/test/define.yaml b/test/define.yaml index 5b6559a5f..d3091a587 100644 --- a/test/define.yaml +++ b/test/define.yaml @@ -282,9 +282,38 @@ unit: coverage: - common/type/pack + # ---------------------------------------------------------------------------------------------------------------------------- + - name: compress + total: 5 + + coverage: + - common/compress/bz2/common + - common/compress/bz2/compress + - common/compress/bz2/decompress + - common/compress/gz/common + - common/compress/gz/compress + - common/compress/gz/decompress + - common/compress/lz4/common + - common/compress/lz4/compress + - common/compress/lz4/decompress + - common/compress/zst/common + - common/compress/zst/compress + - common/compress/zst/decompress + - common/compress/helper + + depend: + - storage/posix/read + - storage/posix/storage + - storage/posix/write + - storage/read + - storage/storage + - storage/write + # ---------------------------------------------------------------------------------------------------------------------------- - name: crypto total: 3 + feature: STORAGE + harness: storage coverage: - common/crypto/cipherBlock @@ -315,14 +344,6 @@ unit: - common/io/fdRead - common/io/read - depend: - - storage/posix/read - - storage/posix/storage - - storage/posix/write - - storage/read - - storage/storage - - storage/write - # ---------------------------------------------------------------------------------------------------------------------------- - name: io-http total: 6 @@ -352,31 +373,12 @@ unit: - common/ini # ---------------------------------------------------------------------------------------------------------------------------- - - name: compress - total: 5 - - coverage: - - common/compress/bz2/common - - common/compress/bz2/compress - - common/compress/bz2/decompress - - common/compress/gz/common - - common/compress/gz/compress - - common/compress/gz/decompress - - common/compress/lz4/common - - common/compress/lz4/compress - - common/compress/lz4/decompress - - common/compress/zst/common - - common/compress/zst/compress - - common/compress/zst/decompress - - common/compress/helper - - # ---------------------------------------------------------------------------------------------------------------------------- - - name: exit + - name: lock total: 3 harness: config coverage: - - common/exit + - common/lock depend: - command/backup/pageChecksum @@ -400,15 +402,6 @@ unit: - storage/remote/storage - storage/remote/write - # ---------------------------------------------------------------------------------------------------------------------------- - - name: lock - total: 3 - feature: STORAGE - harness: storage - - coverage: - - common/lock - # ******************************************************************************************************************************** - name: protocol @@ -846,6 +839,13 @@ unit: coverage: - command/local/local + # ---------------------------------------------------------------------------------------------------------------------------- + - name: exit + total: 3 + + coverage: + - command/exit + # ---------------------------------------------------------------------------------------------------------------------------- - name: server total: 2 diff --git a/test/src/module/common/exitTest.c b/test/src/module/command/exitTest.c similarity index 97% rename from test/src/module/common/exitTest.c rename to test/src/module/command/exitTest.c index 62f5e953a..4244c18fd 100644 --- a/test/src/module/common/exitTest.c +++ b/test/src/module/command/exitTest.c @@ -94,7 +94,7 @@ testRun(void) { exitSafe(0, true, signalTypeNone); TEST_RESULT_LOG( - "P00 DEBUG: " TEST_PGB_PATH "/src/common/exit::exitSafe: (result: 0, error: true, signalType: 0)\n" + "P00 DEBUG: " TEST_PGB_PATH "/src/command/exit::exitSafe: (result: 0, error: true, signalType: 0)\n" "P00 ERROR: [122]: test debug error message\n" " --------------------------------------------------------------------\n" " If SUBMITTING AN ISSUE please provide the following information:\n" @@ -109,7 +109,7 @@ testRun(void) "P00 INFO: archive-push:async command end: aborted with exception [122]\n" "P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: (failOnNoLock: false)\n" "P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: => false\n" - "P00 DEBUG: " TEST_PGB_PATH "/src/common/exit::exitSafe: => 122"); + "P00 DEBUG: " TEST_PGB_PATH "/src/command/exit::exitSafe: => 122"); } TRY_END(); diff --git a/test/src/module/command/serverTest.c b/test/src/module/command/serverTest.c index 861953d15..8a5395d71 100644 --- a/test/src/module/command/serverTest.c +++ b/test/src/module/command/serverTest.c @@ -1,7 +1,7 @@ /*********************************************************************************************************************************** Test Server Command ***********************************************************************************************************************************/ -#include "common/exit.h" +#include "command/exit.h" #include "storage/posix/storage.h" #include "storage/remote/storage.h"