Skip to content

Commit

Permalink
stress-ng: fix teardown
Browse files Browse the repository at this point in the history
Fix the teardown function to prevent AttributeError by adding checks
to see if the attribute and path exists before trying to remove it.

Before fix:
ERROR: 'Stressng' object has no attribute 'loop_dev'
ERROR: 'Stressng' object has no attribute 'stressmnt'

After fix:
CANCEL: Build Failed, Please check the build logs for details !!

Signed-off-by: Disha Goel <[email protected]>
  • Loading branch information
disgoel committed Oct 23, 2024
1 parent d752a5a commit 8b8766c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions generic/stress-ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,12 @@ def test(self):
"\n".join(ERROR))

def tearDown(self):
if 'filesystem' in self.class_type:
if hasattr(self, 'loop_dev') and os.path.exists(self.loop_dev):
process.run("umount %s" % self.loop_dev, ignore_status=True,
sudo=True)
process.run("losetup -d %s" % self.loop_dev, ignore_status=True,
sudo=True)
if os.path.exists('/tmp/blockfile'):
process.run("rm -rf /tmp/blockfile", ignore_status=True, sudo=True)
if (os.path.exists(self.stressmnt)):
process.run(f"rm -rf {self.stressmnt}")
if hasattr(self, 'stressmnt') and os.path.exists(self.stressmnt):
process.run(f"rm -rf {self.stressmnt}", ignore_status=True)

0 comments on commit 8b8766c

Please sign in to comment.