Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Use class methods for downloads #2431

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/sst/elements/cramSim/tests/testsuite_default_cramSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,36 @@

import os
import shutil
import tempfile


class testcase_cramSim_Component(SSTTestCase):
download_file = None

def setUp(self):
super(type(self), self).setUp()
if self.__class__.download_file is None:
self.skipTest("File not downloaded!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when running the tests concurrently? setUpClass is skipped so these tests will always be skipped?

Copy link
Member Author

@jmlapre jmlapre Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the proposed behavior. The fix is more involved than simply calling setUpClass() where initializeClass() is called...

self._setupcramSimTestFiles()

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.download_file = None
cls.downloadFiles()

@classmethod
def downloadFiles(cls):
# create a temp directory
tempdir = tempfile.mkdtemp()

# wget a test file tar.gz
testfile = "sst-cramSim_trace_verimem_trace_files.tar.gz"
fileurl = "https://github.com/sstsimulator/sst-downloads/releases/download/TestFiles/{0}".format(testfile)
cls.assertTrue(os_wget(fileurl, tempdir), "Failed to download {0}".format(testfile))

cls.download_file = f"{tempdir}/{testfile}"

def tearDown(self):
# Put test based teardown code here. it is called once after every test
super(type(self), self).tearDown()
Expand Down Expand Up @@ -137,12 +159,5 @@ def _setupcramSimTestFiles(self):
for f in os.listdir(self.cramSimElementTestsDir):
os_symlink_file(self.cramSimElementTestsDir, self.testcramSimTestsDir, f)

# wget a test file tar.gz
testfile = "sst-cramSim_trace_verimem_trace_files.tar.gz"
fileurl = "https://github.com/sstsimulator/sst-downloads/releases/download/TestFiles/{0}".format(testfile)
self.assertTrue(os_wget(fileurl, self.testcramSimTestsDir), "Failed to download {0}".format(testfile))

# Extract the test file
filename = "{0}/{1}".format(self.testcramSimTestsDir, testfile)
os_extract_tar(filename, self.testcramSimTestsDir)

os_extract_tar(self.__class__.download_file, self.testcramSimTestsDir)
Loading