Exemple #1
0
    def test_invalid_driver(self):
        """Test output from a device tree file with an invalid driver"""
        dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts')
        output = tools.GetOutputFilename('output')
        with test_util.capture_sys_output() as (stdout, stderr):
            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(HEADER + '''
struct dtd_invalid {
};
''', data)

        with test_util.capture_sys_output() as (stdout, stderr):
            dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static struct dtd_invalid dtv_spl_test = {
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "invalid",
\t.platdata\t= &dtv_spl_test,
\t.platdata_size\t= sizeof(dtv_spl_test),
};

void dm_populate_phandle_data(void) {
}
''', data)
Exemple #2
0
    def test_phandle_reorder(self):
        """Test that phandle targets are generated before their references"""
        dtb_file = get_dtb_file('dtoc_test_phandle_reorder.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_target dtv_phandle_target = {
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle_target,
\t.platdata_size\t= sizeof(dtv_phandle_target),
};

static const struct dtd_source dtv_phandle_source2 = {
\t.clocks\t\t\t= {
\t\t\t{&dtv_phandle_target, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
\t.platdata\t= &dtv_phandle_source2,
\t.platdata_size\t= sizeof(dtv_phandle_source2),
};

''', data)
 def testScanDrivers(self):
     """Test running dtoc with additional drivers to scan"""
     dtb_file = get_dtb_file('dtoc_test_simple.dts')
     output = tools.GetOutputFilename('output')
     with test_util.capture_sys_output() as (stdout, stderr):
         dtb_platdata.run_steps(['struct'], dtb_file, False, output, True,
                            [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx'])
Exemple #4
0
    def test_aliases(self):
        """Test output from a node with multiple compatible strings"""
        dtb_file = get_dtb_file('dtoc_test_aliases.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_compat1 {
\tfdt32_t\t\tintval;
};
#define dtd_compat2_1_fred dtd_compat1
#define dtd_compat3 dtd_compat1
''', data)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_compat1 dtv_spl_test = {
\t.intval\t\t\t= 0x1,
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "compat1",
\t.platdata\t= &dtv_spl_test,
\t.platdata_size\t= sizeof(dtv_spl_test),
};

''', data)
Exemple #5
0
    def test_invalid_driver(self):
        """Test output from a device tree file with an invalid driver"""
        dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts')
        output = tools.GetOutputFilename('output')
        with test_util.capture_sys_output() as _:
            dtb_platdata.run_steps(['struct'], dtb_file, False, output, [])
        with open(output) as infile:
            data = infile.read()
        self._check_strings(HEADER + '''
struct dtd_invalid {
};
''', data)

        with test_util.capture_sys_output() as _:
            dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [])
        with open(output) as infile:
            data = infile.read()
        self._check_strings(C_HEADER + '''
/* Node /spl-test index 0 */
static struct dtd_invalid dtv_spl_test = {
};
U_BOOT_DRVINFO(spl_test) = {
\t.name\t\t= "invalid",
\t.plat\t= &dtv_spl_test,
\t.plat_size\t= sizeof(dtv_spl_test),
\t.parent_idx\t= -1,
};

''', data)
Exemple #6
0
 def testBadCommand(self):
     """Test running dtoc with an invalid command"""
     dtb_file = get_dtb_file('dtoc_test_simple.dts')
     output = tools.GetOutputFilename('output')
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps(['invalid-cmd'], dtb_file, False, output)
     self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)",
                   str(e.exception))
Exemple #7
0
 def test_bad_reg(self):
     """Test that a reg property with an invalid type generates an error"""
     # Capture stderr since dtc will emit warnings for this file
     dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
     output = tools.GetOutputFilename('output')
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps(['struct'], dtb_file, False, output)
     self.assertIn("Node 'spl-test' reg property is not an int",
                   str(e.exception))
Exemple #8
0
 def test_phandle_bad2(self):
     """Test a phandle target missing its #*-cells property"""
     dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts',
                             capture_stderr=True)
     output = tools.GetOutputFilename('output')
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps(['struct'], dtb_file, False, output)
     self.assertIn("Node 'phandle-target' has no '#clock-cells' property",
                   str(e.exception))
Exemple #9
0
 def test_phandle_bad(self):
     """Test a node containing an invalid phandle fails"""
     dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts',
                             capture_stderr=True)
     output = tools.GetOutputFilename('output')
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps(['struct'], dtb_file, False, output)
     self.assertIn("Cannot parse 'clocks' in node 'phandle-source'",
                   str(e.exception))
Exemple #10
0
    def run_test(args, dtb_file, output):
        """Run a test using dtoc

        Args:
            args (list of str): List of arguments for dtoc
            dtb_file (str): Filename of .dtb file
            output (str): Filename of output file
        """
        dtb_platdata.run_steps(args, dtb_file, False, output, [], True)
Exemple #11
0
 def test_bad_reg2(self):
     """Test that a reg property with an invalid cell count is detected"""
     # Capture stderr since dtc will emit warnings for this file
     dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
     output = tools.GetOutputFilename('output')
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps(['struct'], dtb_file, False, output)
     self.assertIn(
         "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
         str(e.exception))
Exemple #12
0
    def test_addresses32_64(self):
        """Test output from a node with a 'reg' property with na=1, ns=2"""
        dtb_file = get_dtb_file('dtoc_test_addr32_64.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_test1 {
\tfdt64_t\t\treg[2];
};
struct dtd_test2 {
\tfdt64_t\t\treg[2];
};
struct dtd_test3 {
\tfdt64_t\t\treg[4];
};
''', data)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_test1 dtv_test1 = {
\t.reg\t\t\t= {0x1234, 0x567800000000},
};
U_BOOT_DEVICE(test1) = {
\t.name\t\t= "test1",
\t.platdata\t= &dtv_test1,
\t.platdata_size\t= sizeof(dtv_test1),
};

static const struct dtd_test2 dtv_test2 = {
\t.reg\t\t\t= {0x12345678, 0x9876543210987654},
};
U_BOOT_DEVICE(test2) = {
\t.name\t\t= "test2",
\t.platdata\t= &dtv_test2,
\t.platdata_size\t= sizeof(dtv_test2),
};

static const struct dtd_test3 dtv_test3 = {
\t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3},
};
U_BOOT_DEVICE(test3) = {
\t.name\t\t= "test3",
\t.platdata\t= &dtv_test3,
\t.platdata_size\t= sizeof(dtv_test3),
};

''', data)
Exemple #13
0
    def test_empty_file(self):
        """Test output from a device tree file with no nodes"""
        dtb_file = get_dtb_file('dtoc_test_empty.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            lines = infile.read().splitlines()
        self.assertEqual(HEADER.splitlines(), lines)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            lines = infile.read().splitlines()
        self.assertEqual(C_HEADER.splitlines() + [''], lines)
Exemple #14
0
    def test_phandle_single(self):
        """Test output from a node containing a phandle reference"""
        dtb_file = get_dtb_file('dtoc_test_phandle_single.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_source {
\tstruct phandle_0_arg clocks[1];
};
struct dtd_target {
\tfdt32_t\t\tintval;
};
''', data)
    def testUnicodeError(self):
        """Test running dtoc with an invalid unicode file

        To be able to perform this test without adding a weird text file which
        would produce issues when using checkpatch.pl or patman, generate the
        file at runtime and then process it.
        """
        dtb_file = get_dtb_file('dtoc_test_simple.dts')
        output = tools.GetOutputFilename('output')
        driver_fn = '/tmp/' + next(tempfile._get_candidate_names())
        with open(driver_fn, 'wb+') as df:
            df.write(b'\x81')

        with test_util.capture_sys_output() as (stdout, stderr):
            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True,
                               [driver_fn])
Exemple #16
0
    def test_output_dirs(self):
        """Test outputting files to a directory"""
        # Remove the directory so that files from other tests are not there
        tools._RemoveOutputDir()
        tools.PrepareOutputDir(None)

        # This should create the .dts and .dtb in the output directory
        dtb_file = get_dtb_file('dtoc_test_simple.dts')
        outdir = tools.GetOutputDir()
        fnames = glob.glob(outdir + '/*')
        self.assertEqual(2, len(fnames))

        dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True)
        fnames = glob.glob(outdir + '/*')
        self.assertEqual(4, len(fnames))

        leafs = set(os.path.basename(fname) for fname in fnames)
        self.assertEqual(
            {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'},
            leafs)
Exemple #17
0
    def test_add_prop(self):
        """Test that a subequent node can add a new property to a struct"""
        dtb_file = get_dtb_file('dtoc_test_add_prop.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_sandbox_spl_test {
\tfdt32_t\t\tintarray;
\tfdt32_t\t\tintval;
};
''', data)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_sandbox_spl_test dtv_spl_test = {
\t.intval\t\t\t= 0x1,
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "sandbox_spl_test",
\t.platdata\t= &dtv_spl_test,
\t.platdata_size\t= sizeof(dtv_spl_test),
};

static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
\t.intarray\t\t= 0x5,
};
U_BOOT_DEVICE(spl_test2) = {
\t.name\t\t= "sandbox_spl_test",
\t.platdata\t= &dtv_spl_test2,
\t.platdata_size\t= sizeof(dtv_spl_test2),
};

''', data)
Exemple #18
0
 def test_output_conflict(self):
     """Test a conflict between and output dirs and output file"""
     with self.assertRaises(ValueError) as exc:
         dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True)
     self.assertIn("Must specify either output or output_dirs, not both",
                   str(exc.exception))
Exemple #19
0
    def test_simple(self):
        """Test output from some simple nodes with various types of data"""
        dtb_file = get_dtb_file('dtoc_test_simple.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_sandbox_i2c_test {
};
struct dtd_sandbox_pmic_test {
\tbool\t\tlow_power;
\tfdt64_t\t\treg[2];
};
struct dtd_sandbox_spl_test {
\tbool\t\tboolval;
\tunsigned char\tbytearray[3];
\tunsigned char\tbyteval;
\tfdt32_t\t\tintarray[4];
\tfdt32_t\t\tintval;
\tunsigned char\tlongbytearray[9];
\tunsigned char\tnotstring[5];
\tconst char *\tstringarray[3];
\tconst char *\tstringval;
};
struct dtd_sandbox_spl_test_2 {
};
''', data)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_sandbox_spl_test dtv_spl_test = {
\t.boolval\t\t= true,
\t.bytearray\t\t= {0x6, 0x0, 0x0},
\t.byteval\t\t= 0x5,
\t.intarray\t\t= {0x2, 0x3, 0x4, 0x0},
\t.intval\t\t\t= 0x1,
\t.longbytearray\t\t= {0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10,
\t\t0x11},
\t.notstring\t\t= {0x20, 0x21, 0x22, 0x10, 0x0},
\t.stringarray\t\t= {"multi-word", "message", ""},
\t.stringval\t\t= "message",
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "sandbox_spl_test",
\t.platdata\t= &dtv_spl_test,
\t.platdata_size\t= sizeof(dtv_spl_test),
};

static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
\t.bytearray\t\t= {0x1, 0x23, 0x34},
\t.byteval\t\t= 0x8,
\t.intarray\t\t= {0x5, 0x0, 0x0, 0x0},
\t.intval\t\t\t= 0x3,
\t.longbytearray\t\t= {0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
\t\t0x0},
\t.stringarray\t\t= {"another", "multi-word", "message"},
\t.stringval\t\t= "message2",
};
U_BOOT_DEVICE(spl_test2) = {
\t.name\t\t= "sandbox_spl_test",
\t.platdata\t= &dtv_spl_test2,
\t.platdata_size\t= sizeof(dtv_spl_test2),
};

static const struct dtd_sandbox_spl_test dtv_spl_test3 = {
\t.stringarray\t\t= {"one", "", ""},
};
U_BOOT_DEVICE(spl_test3) = {
\t.name\t\t= "sandbox_spl_test",
\t.platdata\t= &dtv_spl_test3,
\t.platdata_size\t= sizeof(dtv_spl_test3),
};

static const struct dtd_sandbox_spl_test_2 dtv_spl_test4 = {
};
U_BOOT_DEVICE(spl_test4) = {
\t.name\t\t= "sandbox_spl_test_2",
\t.platdata\t= &dtv_spl_test4,
\t.platdata_size\t= sizeof(dtv_spl_test4),
};

static const struct dtd_sandbox_i2c_test dtv_i2c_at_0 = {
};
U_BOOT_DEVICE(i2c_at_0) = {
\t.name\t\t= "sandbox_i2c_test",
\t.platdata\t= &dtv_i2c_at_0,
\t.platdata_size\t= sizeof(dtv_i2c_at_0),
};

static const struct dtd_sandbox_pmic_test dtv_pmic_at_9 = {
\t.low_power\t\t= true,
\t.reg\t\t\t= {0x9, 0x0},
};
U_BOOT_DEVICE(pmic_at_9) = {
\t.name\t\t= "sandbox_pmic_test",
\t.platdata\t= &dtv_pmic_at_9,
\t.platdata_size\t= sizeof(dtv_pmic_at_9),
};

''', data)
Exemple #20
0
    def test_phandle_cd_gpio(self):
        """Test that phandle targets are generated when unsing cd-gpios"""
        dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True)
        with open(output) as infile:
            data = infile.read()
        self._check_strings(C_HEADER + '''
/* Node /phandle2-target index 0 */
static struct dtd_target dtv_phandle2_target = {
\t.intval\t\t\t= 0x1,
};
U_BOOT_DRVINFO(phandle2_target) = {
\t.name\t\t= "target",
\t.plat\t= &dtv_phandle2_target,
\t.plat_size\t= sizeof(dtv_phandle2_target),
\t.parent_idx\t= -1,
};

/* Node /phandle3-target index 1 */
static struct dtd_target dtv_phandle3_target = {
\t.intval\t\t\t= 0x2,
};
U_BOOT_DRVINFO(phandle3_target) = {
\t.name\t\t= "target",
\t.plat\t= &dtv_phandle3_target,
\t.plat_size\t= sizeof(dtv_phandle3_target),
\t.parent_idx\t= -1,
};

/* Node /phandle-source index 2 */
static struct dtd_source dtv_phandle_source = {
\t.cd_gpios\t\t= {
\t\t\t{4, {}},
\t\t\t{0, {11}},
\t\t\t{1, {12, 13}},
\t\t\t{4, {}},},
};
U_BOOT_DRVINFO(phandle_source) = {
\t.name\t\t= "source",
\t.plat\t= &dtv_phandle_source,
\t.plat_size\t= sizeof(dtv_phandle_source),
\t.parent_idx\t= -1,
};

/* Node /phandle-source2 index 3 */
static struct dtd_source dtv_phandle_source2 = {
\t.cd_gpios\t\t= {
\t\t\t{4, {}},},
};
U_BOOT_DRVINFO(phandle_source2) = {
\t.name\t\t= "source",
\t.plat\t= &dtv_phandle_source2,
\t.plat_size\t= sizeof(dtv_phandle_source2),
\t.parent_idx\t= -1,
};

/* Node /phandle-target index 4 */
static struct dtd_target dtv_phandle_target = {
\t.intval\t\t\t= 0x0,
};
U_BOOT_DRVINFO(phandle_target) = {
\t.name\t\t= "target",
\t.plat\t= &dtv_phandle_target,
\t.plat_size\t= sizeof(dtv_phandle_target),
\t.parent_idx\t= -1,
};

''', data)
                  help='set number of processes to use for running tests')
parser.add_option('-t',
                  '--test',
                  action='store_true',
                  dest='test',
                  default=False,
                  help='run tests')
parser.add_option('-T',
                  '--test-coverage',
                  action='store_true',
                  default=False,
                  help='run tests and check for 100% coverage')
(options, args) = parser.parse_args()

# Run our meagre tests
if options.test:
    ret_code = run_tests(options.processes, args)
    sys.exit(ret_code)

elif options.test_coverage:
    RunTestCoverage()

else:
    dtb_platdata.run_steps(args,
                           options.dtb_file,
                           options.include_disabled,
                           options.output,
                           [options.c_output_dir, options.h_output_dir],
                           options.phase,
                           instantiate=options.instantiate)
Exemple #22
0
    def test_phandle(self):
        """Test output from a node containing a phandle reference"""
        dtb_file = get_dtb_file('dtoc_test_phandle.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['struct'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            HEADER + '''
struct dtd_source {
\tstruct phandle_2_arg clocks[4];
};
struct dtd_target {
\tfdt32_t\t\tintval;
};
''', data)

        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static const struct dtd_target dtv_phandle_target = {
\t.intval\t\t\t= 0x0,
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle_target,
\t.platdata_size\t= sizeof(dtv_phandle_target),
};

static const struct dtd_target dtv_phandle2_target = {
\t.intval\t\t\t= 0x1,
};
U_BOOT_DEVICE(phandle2_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle2_target,
\t.platdata_size\t= sizeof(dtv_phandle2_target),
};

static const struct dtd_target dtv_phandle3_target = {
\t.intval\t\t\t= 0x2,
};
U_BOOT_DEVICE(phandle3_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle3_target,
\t.platdata_size\t= sizeof(dtv_phandle3_target),
};

static const struct dtd_source dtv_phandle_source = {
\t.clocks\t\t\t= {
\t\t\t{&dtv_phandle_target, {}},
\t\t\t{&dtv_phandle2_target, {11}},
\t\t\t{&dtv_phandle3_target, {12, 13}},
\t\t\t{&dtv_phandle_target, {}},},
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
\t.platdata\t= &dtv_phandle_source,
\t.platdata_size\t= sizeof(dtv_phandle_source),
};

static const struct dtd_source dtv_phandle_source2 = {
\t.clocks\t\t\t= {
\t\t\t{&dtv_phandle_target, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
\t.platdata\t= &dtv_phandle_source2,
\t.platdata_size\t= sizeof(dtv_phandle_source2),
};

''', data)
Exemple #23
0
                    help='set number of processes to use for running tests')
parser.add_argument('-t',
                    '--test',
                    action='store_true',
                    dest='test',
                    default=False,
                    help='run tests')
parser.add_argument('-T',
                    '--test-coverage',
                    action='store_true',
                    default=False,
                    help='run tests and check for 100%% coverage')
parser.add_argument('files', nargs='*')
args = parser.parse_args()

# Run our meagre tests
if args.test:
    ret_code = run_tests(args.processes, args)
    sys.exit(ret_code)

elif args.test_coverage:
    RunTestCoverage()

else:
    dtb_platdata.run_steps(args.files,
                           args.dtb_file,
                           args.include_disabled,
                           args.output, [args.c_output_dir, args.h_output_dir],
                           args.phase,
                           instantiate=args.instantiate)
Exemple #24
0
    def test_phandle_cd_gpio(self):
        """Test that phandle targets are generated when unsing cd-gpios"""
        dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts')
        output = tools.GetOutputFilename('output')
        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
        with open(output) as infile:
            data = infile.read()
        self._CheckStrings(
            C_HEADER + '''
static struct dtd_target dtv_phandle_target = {
\t.intval\t\t\t= 0x0,
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle_target,
\t.platdata_size\t= sizeof(dtv_phandle_target),
};

static struct dtd_target dtv_phandle2_target = {
\t.intval\t\t\t= 0x1,
};
U_BOOT_DEVICE(phandle2_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle2_target,
\t.platdata_size\t= sizeof(dtv_phandle2_target),
};

static struct dtd_target dtv_phandle3_target = {
\t.intval\t\t\t= 0x2,
};
U_BOOT_DEVICE(phandle3_target) = {
\t.name\t\t= "target",
\t.platdata\t= &dtv_phandle3_target,
\t.platdata_size\t= sizeof(dtv_phandle3_target),
};

static struct dtd_source dtv_phandle_source = {
\t.cd_gpios\t\t= {
\t\t\t{NULL, {}},
\t\t\t{NULL, {11}},
\t\t\t{NULL, {12, 13}},
\t\t\t{NULL, {}},},
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
\t.platdata\t= &dtv_phandle_source,
\t.platdata_size\t= sizeof(dtv_phandle_source),
};

static struct dtd_source dtv_phandle_source2 = {
\t.cd_gpios\t\t= {
\t\t\t{NULL, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
\t.platdata\t= &dtv_phandle_source2,
\t.platdata_size\t= sizeof(dtv_phandle_source2),
};

void dm_populate_phandle_data(void) {
\tdtv_phandle_source.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
\tdtv_phandle_source.cd_gpios[1].node = DM_GET_DEVICE(phandle2_target);
\tdtv_phandle_source.cd_gpios[2].node = DM_GET_DEVICE(phandle3_target);
\tdtv_phandle_source.cd_gpios[3].node = DM_GET_DEVICE(phandle_target);
\tdtv_phandle_source2.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
}
''', data)
Exemple #25
0
 def testStdout(self):
     """Test output to stdout"""
     dtb_file = get_dtb_file('dtoc_test_simple.dts')
     with test_util.capture_sys_output() as (stdout, stderr):
         dtb_platdata.run_steps(['struct'], dtb_file, False, '-')
Exemple #26
0
 def run_test(self, args, dtb_file, output):
     dtb_platdata.run_steps(args, dtb_file, False, output, True)
Exemple #27
0
 def testNoCommand(self):
     """Test running dtoc without a command"""
     with self.assertRaises(ValueError) as e:
         dtb_platdata.run_steps([], '', False, '')
     self.assertIn("Please specify a command: struct, platdata",
                   str(e.exception))
Exemple #28
0
                  help='Select output filename')
parser.add_option('-P',
                  '--processes',
                  type=int,
                  help='set number of processes to use for running tests')
parser.add_option('-t',
                  '--test',
                  action='store_true',
                  dest='test',
                  default=False,
                  help='run tests')
parser.add_option('-T',
                  '--test-coverage',
                  action='store_true',
                  default=False,
                  help='run tests and check for 100% coverage')
(options, args) = parser.parse_args()

# Run our meagre tests
if options.test:
    ret_code = run_tests(options.processes, args)
    sys.exit(ret_code)

elif options.test_coverage:
    RunTestCoverage()

else:
    dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
                           options.output,
                           [options.c_output_dir, options.h_output_dir])
Exemple #29
0
                  default='-',
                  help='Select output filename')
parser.add_option('-P',
                  '--processes',
                  type=int,
                  help='set number of processes to use for running tests')
parser.add_option('-t',
                  '--test',
                  action='store_true',
                  dest='test',
                  default=False,
                  help='run tests')
parser.add_option('-T',
                  '--test-coverage',
                  action='store_true',
                  default=False,
                  help='run tests and check for 100% coverage')
(options, args) = parser.parse_args()

# Run our meagre tests
if options.test:
    ret_code = run_tests(args)
    sys.exit(ret_code)

elif options.test_coverage:
    RunTestCoverage()

else:
    dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
                           options.output)