Skip to contentSkip to conversation

iotests: fix leak of tmpdir in dry-run mode

PATCH Applied Daniel P. Berrangé 4 participants 4 messages Feb 5, 2024 – Feb 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iotests: fix leak of tmpdir in dry-run mode

Creating an instance of the 'TestEnv' class will create a temporary directory. This dir is only deleted, however, in the __exit__ handler invoked by a context manager.

In dry-run mode, we don't use the TestEnv via a context manager, so were leaking the temporary directory. Since meson invokes 'check' 5 times on each configure run, developers /tmp was filling up with empty temporary directories.

---
 tests/qemu-iotests/check | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +2 -1
index f2e9d27dcf..56d88ca423 100755
@@ -184,7 +184,8 @@ if __name__ == '__main__':
         sys.exit(str(e))
 
     if args.dry_run:
-        print('\n'.join([os.path.basename(t) for t in tests]))
+        with env:
+            print('\n'.join([os.path.basename(t) for t in tests]))
     else:
         with TestRunner(env, tap=args.tap,
                         color=args.color) as tr:
Signature · 1 line
2.43.0
#1 lore raw
Quoted 11 lines · Daniel P. Berrangé

Creating an instance of the 'TestEnv' class will create a temporary directory. This dir is only deleted, however, in the __exit__ handler invoked by a context manager.

In dry-run mode, we don't use the TestEnv via a context manager, so were leaking the temporary directory. Since meson invokes 'check' 5 times on each configure run, developers /tmp was filling up with empty temporary directories.

Could we also arrange for the temp directory to be created with a name that makes it easy to identify what has created it? Very generic names like "/tmp/tmpNNNNNNNN" are very hard to pin down to the code that created them.

thanks
-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel P. Berrangé

05.02.2024 18:40, Daniel P. Berrangé :

Quoted 19 lines

Creating an instance of the 'TestEnv' class will create a temporary directory. This dir is only deleted, however, in the __exit__ handler invoked by a context manager.

In dry-run mode, we don't use the TestEnv via a context manager, so were leaking the temporary directory. Since meson invokes 'check' 5 times on each configure run, developers /tmp was filling up with empty temporary directories.

---
  tests/qemu-iotests/check | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +0 -0
index f2e9d27dcf..56d88ca423 100755

tests/qemu-iotests/check if __name__ == '__main__': · line 191

Quoted 9 lines
tests/qemu-iotests/check +2 -1
@@ -184,7 +184,8 @@ if __name__ == '__main__':
          sys.exit(str(e))
 
      if args.dry_run:
-        print('\n'.join([os.path.basename(t) for t in tests]))
+        with env:
+            print('\n'.join([os.path.basename(t) for t in tests]))
      else:
          with TestRunner(env, tap=args.tap,
                          color=args.color) as tr:

(with my limited understanding of this code)

Thanks!

/mjt

Applied
#3 lore raw
In reply to Daniel P. Berrangé

Am 05.02.2024 um 16:40 hat Daniel P. Berrangé geschrieben:

Quoted 10 lines

Creating an instance of the 'TestEnv' class will create a temporary directory. This dir is only deleted, however, in the __exit__ handler invoked by a context manager.

In dry-run mode, we don't use the TestEnv via a context manager, so were leaking the temporary directory. Since meson invokes 'check' 5 times on each configure run, developers /tmp was filling up with empty temporary directories.

Thanks, applied to the block branch.

Kevin