[v3,2/2] Fix RPC configuration file test case

Submitted by Adrian Reber on Dec. 19, 2018, 6:04 p.m.


Message ID 20181219180458.13383-2-adrian@lisas.de
State Accepted
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber Dec. 19, 2018, 6:04 p.m.
From: Adrian Reber <areber@redhat.com>

The relevant test case test_rpc_with_configuration_file_overwriting_rpc()
was actually designed around the broken behaviour. It was only working
if a previous configuration file (set via environment variable in this
case) and the RPC configuration file have the same name. The test case
which tests that RPC configuration file settings are overwriting direct
RPC settings now makes sure that no other configuration file is set via
the environment variable. If it would be set, the test case would still
succeed, even with the previous patch applied. Which is and which was the
correct behaviour.

So the main reason for this change is to test the more likely use case
that the environment based configuration file and the RPC configuration
file have different names.

Signed-off-by: Adrian Reber <areber@redhat.com>
 test/others/rpc/config_file.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/others/rpc/config_file.py b/test/others/rpc/config_file.py
index f21d194b0..df3d1873e 100755
--- a/test/others/rpc/config_file.py
+++ b/test/others/rpc/config_file.py
@@ -33,10 +33,18 @@  def setup_config_file(content):
 def cleanup_config_file(path):
-	del os.environ['CRIU_CONFIG_FILE']
+	if os.environ.get('CRIU_CONFIG_FILE', None) is not None:
+		del os.environ['CRIU_CONFIG_FILE']
+def cleanup_output(path):
+	for f in (does_not_exist, log_file):
+		f = os.path.join(path, f)
+		if os.access(f, os.F_OK):
+			os.unlink(f)
 def setup_criu_dump_request():
 	# Create criu msg, set it's type to dump request
 	# and set dump options. Checkout more options in protobuf/rpc.proto
@@ -146,6 +154,9 @@  def test_rpc_with_configuration_file_overwriting_rpc():
 	content = 'log-file ' + log + '\n'
 	content += 'no-tcp-established\nno-shell-job'
 	path = setup_config_file(content)
+	# Only set the configuration file via RPC;
+	# not via environment variable
+	del os.environ['CRIU_CONFIG_FILE']
 	req = setup_criu_dump_request()
 	req.opts.config_file = path
 	_, s = setup_swrk()
@@ -160,14 +171,13 @@  parser.add_argument('dir', type = str, help = "Directory where CRIU images shoul
 args = vars(parser.parse_args())
-	# optional cleanup
-	os.unlink(os.path.join(args['dir'], does_not_exist))
-	os.unlink(os.path.join(args['dir'], log_file))
-except OSError:
-	pass