#50922 Issue 50920 - cl-dump exit code is 0 even if command fails with invalid arguments
Closed 3 years ago by spichugi. Opened 4 years ago by spichugi.
spichugi/389-ds-base fix-legacy-cl-dump  into  master

@@ -275,9 +275,7 @@ 

      proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE)

      msg = proc.communicate()

      log.info('output message : %s' % msg[0])

-     # Waiting for bz1769296 fix, rc=0 is expected, so that the next steps be executed - to be changed when bz fixed.

-     #assert proc.returncode != 0

-     assert proc.returncode == 0

+     assert proc.returncode != 0

      

      # Now the core goal of the test case

      # Using cl-dump without -l option

@@ -101,16 +101,17 @@ 

  	}

  

  	if (!$opt_i) {

- 		&cl_dump_and_decode;

+ 		$rc = &cl_dump_and_decode;

  	}

  	elsif ($opt_c) {

- 		&grep_csn ($opt_i);

+ 		$rc = &grep_csn ($opt_i);

  	}

  	else {

- 		&cl_decode ($opt_i);

+ 		$rc = &cl_decode ($opt_i);

  	}

  

  	close (OUTPUT);

+ 	exit($rc);

  }

  

  # Validate the parameters
@@ -209,6 +210,7 @@ 

  		&print_header ($replica, "Not Found") if !$gotldif;

  	}

  	$conn->close;

+ 	return 0;

  }

  

  sub print_header
@@ -260,6 +262,7 @@ 

  		printf OUTPUT "; $modts" if $modts;

  		printf OUTPUT ")\n";

  	}

+ 	return 0;

  }

  

  sub csn_to_string
@@ -316,4 +319,5 @@ 

  		/^\s*(\S+)\s*\n/;

  		$encoded .= $1;

  	}

+ 	return 0;

  }

Description of problem:
When running the cl-dump.pl script with invalid arguments, the exit code is always 0, even if an error message is reported

Fix Description:
Pass the return code to the end of the #main.

https://pagure.io/389-ds-base/issue/50920

Reviewed by: ?

1 new commit added

  • Fix CI test
4 years ago

Code fix looks good to me

rebased onto 245d894

4 years ago

Pull-Request has been merged by spichugi

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3975

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago