diff options
author | Jose <jose@zeroc.com> | 2016-04-07 19:07:10 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-04-07 19:07:10 +0200 |
commit | 538771b59abc2dedbf163abdc4df282224ae4d18 (patch) | |
tree | 51350d8db53fccfae5c3c9f5d6ff5ffe3b0d99ba /cpp/test | |
parent | ICE-7035 - Add option to roll log files (diff) | |
download | ice-538771b59abc2dedbf163abdc4df282224ae4d18.tar.bz2 ice-538771b59abc2dedbf163abdc4df282224ae4d18.tar.xz ice-538771b59abc2dedbf163abdc4df282224ae4d18.zip |
Do not throw if log rotation fails.
If log rotate fails because the file cannot be renamed
we will keep using the same log file or in case that it
cannot be reopen we will log to stderr.
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/Ice/logger/Client5.cpp | 21 | ||||
-rwxr-xr-x | cpp/test/Ice/logger/run.py | 43 |
2 files changed, 56 insertions, 8 deletions
diff --git a/cpp/test/Ice/logger/Client5.cpp b/cpp/test/Ice/logger/Client5.cpp index 5948e2eed9c..b28dcf8dd94 100644 --- a/cpp/test/Ice/logger/Client5.cpp +++ b/cpp/test/Ice/logger/Client5.cpp @@ -135,4 +135,25 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } } + + // + // Run Client application configured to generate 1024 bytes, the application is configured + // to archive log files greater than 512 bytes, but the log directory is set to read only + // after the log file is created, there must not be any archived log files and the log file + // will contain an error indicating the failure to archive the log file + // + { + Ice::InitializationData id; + id.properties = Ice::createProperties(); + id.properties->load("config.client"); + id.properties->setProperty("Client.Iterations", "8"); + id.properties->setProperty("Client.Message", message); + id.properties->setProperty("Ice.LogFile", "log/client5-4.log"); + id.properties->setProperty("Ice.LogFile.SizeMax", "512"); + Client c; + if(c.main(argc, argv, id) != EXIT_SUCCESS) + { + return EXIT_FAILURE; + } + } } diff --git a/cpp/test/Ice/logger/run.py b/cpp/test/Ice/logger/run.py index 1b645a5a5d2..0cc58ebc4ab 100755 --- a/cpp/test/Ice/logger/run.py +++ b/cpp/test/Ice/logger/run.py @@ -58,20 +58,36 @@ sys.stdout.write("testing logger file rotation... ") def cleanup(): for f in glob.glob("client5-*.log"): os.remove(f) + if os.path.exists("log/client5-4.log"): + os.remove("log/client5-4.log") cleanup() atexit.register(cleanup) -def client5(): - p = subprocess.Popen(os.path.join(os.getcwd(), "client5"), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) - out, err = p.communicate() - ret = p.poll() - if ret != 0: - print("failed! status %s " % ret) - sys.exit(1) -client5() +if not os.path.exists("log"): + os.makedirs("log") + +open("log/client5-4.log", 'a').close() + +if TestUtil.isWin32(): + os.system("echo Y|cacls log /P %USERNAME%:R") +else: + os.system("chmod -w log") + + +p = subprocess.Popen(os.path.join(os.getcwd(), "client5"), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) +out, err = p.communicate() +ret = p.poll() +if ret != 0: + print("failed! status %s " % ret) + sys.exit(1) + +if TestUtil.isWin32(): + os.system("echo Y|cacls log /P %USERNAME%:F") +else: + os.system("chmod +w log") if (not os.path.isfile("client5-0.log") or not os.stat("client5-0.log").st_size == 512 or @@ -112,4 +128,15 @@ for f in glob.glob("client5-3-*.log"): print("failed! file {0} size: {1} unexpected".format(f, os.stat(f).st_size)) sys.exit(1) +if (not os.path.isfile("log/client5-4.log") or + os.stat("log/client5-4.log").st_size < 1024 or + len(glob.glob("log/client5-4-*.log")) > 0): + print("failed!") + sys.exit(1) + +with open("log/client5-4.log", 'r') as f: + if f.read().count("error: FileLogger: cannot rename log/client5-4.log") != 1: + print("failed!") + sys.exit(1) + print("ok") |