[PATCH 1/1] Fix trace parameter invocation

Jouni Malinen j at w1.fi
Mon Feb 24 16:23:33 EST 2014


On Mon, Feb 24, 2014 at 04:25:03PM -0400, Eduardo Abinader wrote:
> This patch avoids run-tests to keep hanging in a loop,
> by simply checking inexistence of trace-cmd command
> and exiting the script.

> diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py
> @@ -102,6 +102,11 @@ class DataCollector(object):
>      def __enter__(self):
>          if self._tracing:
>              output = os.path.join(self._logdir, '%s.dat' % (self._testname, ))
> +            if subprocess.call(["type trace-cmd"], shell=True, 
> +                               stdout=subprocess.PIPE, 
> +                               stderr=subprocess.PIPE):
> +                print "failed: trace-cmd not found"
> +                sys.exit(1)
>              self._trace_cmd = subprocess.Popen(['sudo', 'trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', 'sh', '-c', 'echo STARTED ; read l'],
>                                                 stdin=subprocess.PIPE,
>                                                 stdout=subprocess.PIPE,

That looks pretty ugly.. Isn't there any convenient way of making the
following loop break out in case the popen call exits? That would sound
quite a bit cleaner and also free of (admittedly theoretical) race
condition on trace-cmd disappearing between the two calls.
 
-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list