1 # SPDX-License-Identifier: LGPL-3-or-later
2 # Copyright 2022 Jacob Lifshay
5 from openpower
.test
.algorithms
.svp64_utf_8_validation
import \
6 SVP64UTF8ValidationTestCase
7 from openpower
.test
.runner
import TestRunnerBase
8 from functools
import lru_cache
10 # writing the test_caller invocation this way makes it work with pytest
15 # cache globally, so we only have to create test_data once per process
16 return SVP64UTF8ValidationTestCase().test_data
19 class TestSVP64UTF8ValidationBase(TestRunnerBase
):
22 # split up test cases into SPLIT_COUNT tests, so we get some parallelism
26 def __init__(self
, test
):
27 assert test
== 'test', f
"test={test!r}"
29 assert self
.SPLIT_INDEX
!= -1, "must be overridden"
30 # split cases evenly over tests
31 start
= (len(cases
) * self
.SPLIT_INDEX
) // self
.SPLIT_COUNT
32 end
= (len(cases
) * (self
.SPLIT_INDEX
+ 1)) // self
.SPLIT_COUNT
33 # if we have less cases than tests, move them all to the beginning,
34 # making finding failures faster
35 if len(cases
) < self
.SPLIT_COUNT
:
38 if self
.SPLIT_INDEX
< len(cases
):
39 start
= self
.SPLIT_INDEX
41 # can't do raise SkipTest if `start == end`, it makes unittest break
42 super().__init
__(cases
[start
:end
])
45 def make_split_classes(cls
):
46 for i
in range(cls
.SPLIT_COUNT
):
48 class TestSVP64UTF8Validation{i}(TestSVP64UTF8ValidationBase):
53 # dummy function to make unittest try to test this class
58 TestSVP64UTF8ValidationBase
.make_split_classes()
60 if __name__
== "__main__":