1 # SPDX-License-Identifier: LGPL-3-or-later
2 # Copyright 2022 Jacob Lifshay
5 from functools
import lru_cache
7 from openpower
.test
.algorithms
.svp64_utf_8_validation
import \
8 SVP64UTF8ValidationTestCase
9 from openpower
.test
.runner
import TestRunnerBase
11 # writing the test_caller invocation this way makes it work with pytest
16 # cache globally, so we only have to create test_data once per process
17 return SVP64UTF8ValidationTestCase().test_data
20 class TestSVP64UTF8ValidationBase(TestRunnerBase
):
23 # split up test cases into SPLIT_COUNT tests, so we get some parallelism
27 def __init__(self
, test
):
28 assert test
== 'test', f
"test={test!r}"
29 self
.__old
_silence
_log
= os
.environ
.get("SILENCELOG")
31 assert self
.SPLIT_INDEX
!= -1, "must be overridden"
32 # split cases evenly over tests
33 start
= (len(cases
) * self
.SPLIT_INDEX
) // self
.SPLIT_COUNT
34 end
= (len(cases
) * (self
.SPLIT_INDEX
+ 1)) // self
.SPLIT_COUNT
35 # if we have less cases than tests, move them all to the beginning,
36 # making finding failures faster
37 if len(cases
) < self
.SPLIT_COUNT
:
40 if self
.SPLIT_INDEX
< len(cases
):
41 start
= self
.SPLIT_INDEX
43 # can't do raise SkipTest if `start == end`, it makes unittest break
44 super().__init
__(cases
[start
:end
], use_mmap_mem
=True)
48 if self
.__old
_silence
_log
is None:
49 os
.environ
["SILENCELOG"] = "!*,default"
53 if self
.__old
_silence
_log
is None:
54 del os
.environ
["SILENCELOG"]
57 def make_split_classes(cls
):
58 for i
in range(cls
.SPLIT_COUNT
):
60 class TestSVP64UTF8Validation{i}(TestSVP64UTF8ValidationBase):
65 # dummy function to make unittest try to test this class
70 TestSVP64UTF8ValidationBase
.make_split_classes()
72 if __name__
== "__main__":