powerprofilesctl: Exit with launched process exit code

This is a regression of commit 18a9c6668, due to the fact that the
argparse func return value is simply ignored.

So let's just exit directly with the provided return value in such case.
This commit is contained in:
Marco Trevisan (Treviño) 2024-04-01 15:12:25 +02:00 committed by Mario Limonciello
parent 9bc5643950
commit 15c74efc7e
2 changed files with 15 additions and 2 deletions

View file

@ -139,7 +139,7 @@ def _launch(args):
ret = launched_app.returncode
proxy.ReleaseProfile("(u)", cookie)
return ret
sys.exit(ret)
def get_parser():

View file

@ -1760,6 +1760,18 @@ class Tests(dbusmock.DBusTestCase):
tool_cmd + ["--foo-arg", "launch", "true"], stderr=subprocess.PIPE
)
def test_launch_with_command_failure(self):
self.create_platform_profile()
self.start_daemon()
self.assert_eventually(lambda: self.get_dbus_property("ActiveProfile"))
tool_cmd = self.powerprofilesctl_command()
cmd = subprocess.run(tool_cmd + ["launch", "false"], check=False)
self.assertEqual(cmd.returncode, 1)
cmd = subprocess.run(tool_cmd + ["launch", "sh", "-c", "exit 55"], check=False)
self.assertEqual(cmd.returncode, 55)
def test_vanishing_hold(self):
self.create_platform_profile()
self.start_daemon()
@ -1780,7 +1792,8 @@ class Tests(dbusmock.DBusTestCase):
# Make sure to handle vanishing clients
launch_process.terminate()
self.assertEqual(launch_process.wait(), 0)
retcode = launch_process.wait()
self.assertTrue(os.WIFSIGNALED(retcode))
holds = self.get_dbus_property("ActiveProfileHolds")
self.assertEqual(len(holds), 0)