def testEcCodegenWithOneBoard(self): input_json_path = os.path.join(this_dir, '../libcros_config/test_build.json') input_json = open(input_json_path).read() h_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_one.h') c_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_one.c') h_expected = open(h_expected_path).read() c_expected = open(c_expected_path).read() h_actual, c_actual = cros_config_schema.GenerateEcCBindings(input_json) self.assertMultilineStringEqual(h_expected, h_actual) self.assertMultilineStringEqual(c_expected, c_actual)
def testEcCodegenWithNoBoards(self): input_json = """ { "chromeos": { "configs": [] } } """ h_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_none.h') c_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_none.c') h_expected = open(h_expected_path).read() c_expected = open(c_expected_path).read() h_actual, c_actual = cros_config_schema.GenerateEcCBindings(input_json) self.assertMultilineStringEqual(h_expected, h_actual) self.assertMultilineStringEqual(c_expected, c_actual)
def testEcCodegenManyBoards(self): input_json = """ { "chromeos": { "configs": [ { "firmware": { "build-targets": { "ec": "Another" } }, "hardware-properties": { "is-lid-convertible": false, "has-base-accelerometer": true, "has-lid-accelerometer": true }, "identity": { "sku-id": 40 } }, { "firmware": { "build-targets": { "ec": "Some" } }, "hardware-properties": { "is-lid-convertible": false, "has-base-accelerometer": true, "has-lid-accelerometer": true, "stylus-category": "external" }, "identity": { "sku-id": 9 } }, { "firmware": { "build-targets": { "ec": "Some" } }, "hardware-properties": { "is-lid-convertible": true, "has-lid-accelerometer": true }, "identity": { "sku-id": 99 } } ] } } """ h_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_many.h') c_expected_path = os.path.join(this_dir, '../libcros_config/ec_test_many.c') h_expected = osutils.ReadFile(h_expected_path) c_expected = osutils.ReadFile(c_expected_path) h_actual, c_actual = cros_config_schema.GenerateEcCBindings( input_json, self._GetSchemaYaml()) self.assertMultilineStringEqual(h_expected, h_actual) self.assertMultilineStringEqual(c_expected, c_actual)