Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / 'tools/toolchain'))
|
||||
from runtime_inputs import STANDALONE_FILES, validate_private_inputs
|
||||
|
||||
|
||||
class RuntimeInputsTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
hashes = {}
|
||||
for name in STANDALONE_FILES:
|
||||
path = self.root / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(name.encode())
|
||||
hashes[name] = hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
self.record = {'privateRuntimeInputs': True, 'standaloneDisk': {
|
||||
'profile': 'decb-derived-standalone', 'license': 'public-domain-except-DECB-derived-portions',
|
||||
'sourceSHA256': 'a' * 64, 'filesSHA256': hashes}}
|
||||
|
||||
def testExplicitExtensionAndSourceOnlyRuntime(self):
|
||||
validate_private_inputs(self.root, self.record)
|
||||
for name in STANDALONE_FILES:
|
||||
if not name.endswith('.h'): (self.root / name).unlink()
|
||||
validate_private_inputs(self.root, {'privateRuntimeInputs': False})
|
||||
|
||||
def testUndeclaredPrivatePayloadRejected(self):
|
||||
with self.assertRaises(ValueError): validate_private_inputs(self.root, {'privateRuntimeInputs': False})
|
||||
with self.assertRaises(ValueError): validate_private_inputs(self.root, {'privateRuntimeInputs': True})
|
||||
|
||||
def testMissingOrModifiedNoticeRejected(self):
|
||||
notice = self.root / 'LICENSES/DSKCON-STANDALONE-NOTICE.txt'
|
||||
notice.write_text('incorrect GPL-only notice')
|
||||
with self.assertRaises(ValueError): validate_private_inputs(self.root, self.record)
|
||||
notice.unlink()
|
||||
with self.assertRaises(ValueError): validate_private_inputs(self.root, self.record)
|
||||
|
||||
def testManifestCannotDeclareArbitraryPrivatePaths(self):
|
||||
self.record['standaloneDisk']['filesSHA256']['../outside'] = 'a' * 64
|
||||
with self.assertRaises(ValueError): validate_private_inputs(self.root, self.record)
|
||||
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
||||
Reference in new issue
Block a user