Skip to content

Commit

Permalink
Add test metrics, install missing tools to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
vmilosevic committed Nov 22, 2024
1 parent 2c771b4 commit a815130
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .github/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ RUN apt-get update && apt-get install -y \
graphviz \
patchelf \
libyaml-cpp-dev \
libboost-all-dev
libboost-all-dev \
curl \
jq \
sudo

# Install clang 17
RUN wget https://apt.llvm.org/llvm.sh && \
Expand Down
3 changes: 2 additions & 1 deletion .github/Dockerfile.ird
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN apt-get update && apt-get install -y \
ssh \
sudo \
wget \
vim
vim \
gh

# Create a directory for the toolchain and set permissions
RUN mkdir -p $TTMLIR_TOOLCHAIN_DIR && \
Expand Down
25 changes: 7 additions & 18 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,16 @@
import lit.formats
import lit.util
from lit.llvm import llvm_config
from lit.formats.base import TestFormat

# Add the current folder to PYTHONPATH
current_folder = os.path.dirname(__file__)
sys.path.append(current_folder)
os.environ["PYTHONPATH"] = current_folder + os.pathsep + os.environ.get("PYTHONPATH", "")
from timestamped_test_format import TimestampedTestFormat

# Configuration file for the 'lit' test runner.

class TimestampedTestFormat(TestFormat):
def __init__(self):
super().__init__('Timestamped Test')

def execute(self, test, lit_config):
start_timestamp = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
test.setMetric('start_timestamp', start_timestamp)

# Run the test
result = lit.TestRunner.executeShTest(test, lit_config)

end_timestamp = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
test.setMetric('end_timestamp', end_timestamp)
# Configuration file for the 'lit' test runner.

return result

def set_system_desc_features(system_desc):
config.available_features.add(system_desc["chip_descs"][0]["arch"])
if len(system_desc["chip_desc_indices"]) > 1:
Expand All @@ -40,8 +29,8 @@ def set_system_desc_features(system_desc):

# name: The name of this test suite.
config.name = "TTMLIR"

config.test_format = TimestampedTestFormat()
# config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)

# Stablehlo tests can be optionally enabled.
if config.enable_stablehlo:
Expand Down
22 changes: 22 additions & 0 deletions test/timestamped_test_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import datetime
import lit.Test
from lit.formats.shtest import ShTest
from lit.Test import toMetricValue
import lit.TestRunner

from unittest.mock import patch

class TimestampedTestFormat(ShTest):
def __init__(self):
super().__init__()

def execute(self, test, lit_config):
start_timestamp = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
# Run the test
result = lit.TestRunner.executeShTest(test, lit_config, True)
end_timestamp = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
result.addMetric("start_timestamp", toMetricValue(start_timestamp))
result.addMetric("end_timestamp", toMetricValue(end_timestamp))

return result

0 comments on commit a815130

Please sign in to comment.