Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/oniro-core/sysota
  • pastanki/sysota
2 results
Show changes
Commits on Source (2)
......@@ -121,10 +121,10 @@ func (s *bootConfigSuite) TestNewBootConfig(c *C) {
// Providing a bogus revision fails early on, since we look for the board type.
_, err = piboot.NewBootConfig(s.bootDir, 0, sampleSerial)
c.Assert(err, ErrorMatches, `cannot use boot configuration: cannot decode revision code 0x0000, unknown board type`)
c.Assert(err, ErrorMatches, `cannot use boot configuration: cannot decode revision code 0000, unknown board type`)
// Wrapped errors can be unwrapped.
c.Assert(errors.Unwrap(err), ErrorMatches, `cannot decode revision code 0x0000, unknown board type`)
c.Assert(errors.Unwrap(err), ErrorMatches, `cannot decode revision code 0000, unknown board type`)
// An existing but corrupted ConfigTxt is detected early on.
// Depending on where the corruption is (invalid syntax vs valid but unrecognized syntax), the
......
......@@ -109,7 +109,7 @@ func (s *simSuite) TestNewSimulatorInvalidFilter(c *C) {
func (s *simSuite) TestNewSimulatorInvalidRevision(c *C) {
cfg := &picfg.ConfigTxt{}
_, err := condfilter.NewSimulator(cfg, 0, sampleSerial)
c.Assert(err, ErrorMatches, `cannot decode revision code 0x0000, unknown board type`)
c.Assert(err, ErrorMatches, `cannot decode revision code 0000, unknown board type`)
}
func (s *simSuite) TestConditionalFilters(c *C) {
......
......@@ -59,11 +59,29 @@ const (
// String returns the revision code as a hexadecimal string.
func (code RevisionCode) String() string {
// The selected format is that of /proc/cpuinfo.
if code < 16 {
return fmt.Sprintf("%#04x", uint(code))
return fmt.Sprintf("%04x", uint(code))
}
return fmt.Sprintf("%#06x", uint(code))
return fmt.Sprintf("%06x", uint(code))
}
// MarshalText implements encoding.TextMarshaler.
func (revCode RevisionCode) MarshalText() ([]byte, error) {
return []byte(revCode.String()), nil
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (revCode *RevisionCode) UnmarshalText(text []byte) error {
n, err := strconv.ParseUint(string(text), 0, 32)
if err != nil {
return err
}
*revCode = RevisionCode(n)
return nil
}
// newFlag returns true if the revision code uses new-style format.
......
......@@ -18,8 +18,31 @@ var _ = Suite(&revCodeSuite{})
func (s *revCodeSuite) TestString(c *C) {
// Both old and new style revisions are represented the way people might expect.
c.Check(pimodel.RevisionCode(0x0004).String(), Equals, "0x0004")
c.Check(pimodel.RevisionCode(0xa03140).String(), Equals, "0xa03140")
c.Check(pimodel.RevisionCode(0x0004).String(), Equals, "0004")
c.Check(pimodel.RevisionCode(0xa03140).String(), Equals, "a03140")
}
func (s *revCodeSuite) TestMarshalText(c *C) {
revCode := pimodel.RevisionCode(0x0004)
data, err := revCode.MarshalText()
c.Assert(err, IsNil)
c.Check(data, DeepEquals, []byte("0004"))
revCode = pimodel.RevisionCode(0xa03140)
data, err = revCode.MarshalText()
c.Assert(err, IsNil)
c.Check(data, DeepEquals, []byte("a03140"))
}
func (s *revCodeSuite) TestUnmarshalText(c *C) {
var revCode pimodel.RevisionCode
err := revCode.UnmarshalText([]byte("0004"))
c.Assert(err, IsNil)
c.Check(revCode, Equals, pimodel.RevisionCode(0x0004))
err = revCode.UnmarshalText([]byte("potato"))
c.Assert(err, ErrorMatches, `strconv.ParseUint: parsing "potato": invalid syntax`)
}
func (s *revCodeSuite) TestKnownRevisionCodes(c *C) {
......@@ -452,27 +475,27 @@ func (s *revCodeSuite) TestKnownRevisionCodes(c *C) {
func (s *revCodeSuite) TestWonkyMemorySize(c *C) {
_, err := pimodel.RevisionCode(0x0).MemorySize()
c.Assert(err, ErrorMatches, `cannot decode revision code 0x0000, unknown memory size`)
c.Assert(err, ErrorMatches, `cannot decode revision code 0000, unknown memory size`)
}
func (s *revCodeSuite) TestWonkyManufacturer(c *C) {
_, err := pimodel.RevisionCode(0x0).Manufacturer()
c.Assert(err, ErrorMatches, `cannot decode revision code 0x0000, unknown manufacturer`)
c.Assert(err, ErrorMatches, `cannot decode revision code 0000, unknown manufacturer`)
}
func (s *revCodeSuite) TestWonkyProcessor(c *C) {
_, err := pimodel.RevisionCode((5 << 12) | (1 << 23)).Processor() // 5th SoC | new flag
c.Assert(err, ErrorMatches, `cannot decode revision code 0x805000, unknown processor`)
c.Assert(err, ErrorMatches, `cannot decode revision code 805000, unknown processor`)
}
func (s *revCodeSuite) TestWonkyRevision(c *C) {
_, err := pimodel.RevisionCode(0x0001).BoardRevision()
c.Assert(err, ErrorMatches, `cannot decode revision code 0x0001, unknown board revision`)
c.Assert(err, ErrorMatches, `cannot decode revision code 0001, unknown board revision`)
}
func (s *revCodeSuite) TestWonkyBoardType(c *C) {
_, err := pimodel.RevisionCode(0x0001).BoardType()
c.Assert(err, ErrorMatches, `cannot decode revision code 0x0001, unknown board type`)
c.Assert(err, ErrorMatches, `cannot decode revision code 0001, unknown board type`)
}
type probeCpuinfoSuite struct{}
......