-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from PDXCapstoneF/bs-compliant-run
Do (limited) compliant run validation. Closes #167.
- Loading branch information
Showing
5 changed files
with
160 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
This module defines ways to validate that a run is compliant | ||
or not according to https://www.spec.org/jbb2015/docs/runrules.pdf. | ||
""" | ||
from schema import Schema, And, Or, Optional | ||
from src.validate import is_stringy | ||
|
||
def compliant(props=None): | ||
""" | ||
Returns a boolean representing whether or not a run is compliant. | ||
Props is a dictionary of key => value pairs representing SPECjbb properties. | ||
""" | ||
if props is None: | ||
return True | ||
|
||
try: | ||
return CompliantRunSchema.validate(props) is not None | ||
except Exception: | ||
return False | ||
|
||
CompliantRunSchema = Schema({ | ||
Optional("specjbb.group.count"): And(int, lambda group_count: group_count >= 1), | ||
Optional("specjbb.txi.pergroup.count"): And(int, lambda injector_count: injector_count >= 1), | ||
Optional("specjbb.mapreducer.pool.size"): And(int, lambda pool_size: pool_size >= 2), | ||
Optional(is_stringy): object, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import unittest | ||
from src import compliant | ||
|
||
class TestComplianceProps(unittest.TestCase): | ||
def test_defaults_are_compliant(self): | ||
self.assertTrue(compliant.compliant()) | ||
self.assertTrue(compliant.compliant({})) | ||
|
||
def test_group_count_must_be_compliant(self): | ||
self.assertFalse(compliant.compliant({ | ||
"specjbb.group.count": -1, | ||
})) | ||
|
||
def test_transaction_injector_count_must_be_compliant(self): | ||
self.assertFalse(compliant.compliant({ | ||
"specjbb.txi.pergroup.count": -1, | ||
})) | ||
|
||
def test_mapreducer_must_be_compliant(self): | ||
self.assertFalse(compliant.compliant({ | ||
"specjbb.mapreducer.pool.size": 1, | ||
})) |