From 171dc2d9330d21e2f4f7d6c88f6e1934536cc12d Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Wed, 2 Aug 2023 12:00:00 -0700 Subject: [PATCH] Don't depend on current working directory in test --- tools/metrics/ukm/gen_builders_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/metrics/ukm/gen_builders_test.py b/tools/metrics/ukm/gen_builders_test.py index be807ad50da3..fefcd9cc685f 100755 --- a/tools/metrics/ukm/gen_builders_test.py +++ b/tools/metrics/ukm/gen_builders_test.py @@ -13,11 +13,13 @@ from decode_template import IMPL as DECODE_IMPL_TEMPLATE import ukm_model import gen_builders +import os +_FILE_DIR = os.path.dirname(__file__) class GenBuildersTest(unittest.TestCase): def testFilterObsoleteMetrics(self): - data = gen_builders.ReadFilteredData('../../tools/metrics/ukm/ukm.xml') + data = gen_builders.ReadFilteredData(_FILE_DIR + '/ukm.xml') for event in data[ukm_model._EVENT_TYPE.tag]: self.assertTrue(ukm_model.IsNotObsolete(event)) for metric in event[ukm_model._METRIC_TYPE.tag]: @@ -25,7 +27,7 @@ def testFilterObsoleteMetrics(self): def testGenerateCode(self): relpath = '.' - with open('../../tools/metrics/ukm/ukm.xml') as f: + with open(_FILE_DIR + '/ukm.xml') as f: data = ukm_model.UKM_XML_TYPE.Parse(f.read()) event = data[ukm_model._EVENT_TYPE.tag][0] metric = event[ukm_model._METRIC_TYPE.tag][0]