summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2016-02-15 17:48:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-16 11:17:10 +0000
commit7a700f59d98ffe08714582532d3edb97abc2e33e (patch)
tree5a4bcc4afe511799e38ab386fd7c339c935f94f8 /meta/lib
parent334e1b5e0ee52f201379aee2d3b4d39943ee19e4 (diff)
downloadpoky-7a700f59d98ffe08714582532d3edb97abc2e33e.tar.gz
lib/qa.py: raise ValueError if file isn't an ELF
Instead of raising a generic Exception that can't be handled specifically, raise a ValueError. Also update the callers so any unexpected exceptions are not ignored. Also, rename isBigEngian() to isBigEndian(). (From OE-Core rev: c136652f9c0b35aafa393e63567daf029ae03929) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/qa.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 21fb9977ce..2ad6c63bdc 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -23,7 +23,7 @@ class ELFFile:
23 def my_assert(self, expectation, result): 23 def my_assert(self, expectation, result):
24 if not expectation == result: 24 if not expectation == result:
25 #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) 25 #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
26 raise Exception("This does not work as expected") 26 raise ValueError("%s is not an ELF" % self.name)
27 27
28 def __init__(self, name, bits = 0): 28 def __init__(self, name, bits = 0):
29 self.name = name 29 self.name = name
@@ -32,7 +32,7 @@ class ELFFile:
32 32
33 def open(self): 33 def open(self):
34 if not os.path.isfile(self.name): 34 if not os.path.isfile(self.name):
35 raise Exception("File is not a normal file") 35 raise ValueError("%s is not a normal file" % self.name)
36 36
37 self.file = file(self.name, "r") 37 self.file = file(self.name, "r")
38 self.data = self.file.read(ELFFile.EI_NIDENT+4) 38 self.data = self.file.read(ELFFile.EI_NIDENT+4)
@@ -49,24 +49,24 @@ class ELFFile:
49 self.bits = 64 49 self.bits = 64
50 else: 50 else:
51 # Not 32-bit or 64.. lets assert 51 # Not 32-bit or 64.. lets assert
52 raise Exception("ELF but not 32 or 64 bit.") 52 raise ValueError("ELF but not 32 or 64 bit.")
53 elif self.bits == 32: 53 elif self.bits == 32:
54 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) 54 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
55 elif self.bits == 64: 55 elif self.bits == 64:
56 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) 56 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
57 else: 57 else:
58 raise Exception("Must specify unknown, 32 or 64 bit size.") 58 raise ValueError("Must specify unknown, 32 or 64 bit size.")
59 self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) 59 self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
60 60
61 self.sex = self.data[ELFFile.EI_DATA] 61 self.sex = self.data[ELFFile.EI_DATA]
62 if self.sex == chr(ELFFile.ELFDATANONE): 62 if self.sex == chr(ELFFile.ELFDATANONE):
63 raise Exception("self.sex == ELFDATANONE") 63 raise ValueError("self.sex == ELFDATANONE")
64 elif self.sex == chr(ELFFile.ELFDATA2LSB): 64 elif self.sex == chr(ELFFile.ELFDATA2LSB):
65 self.sex = "<" 65 self.sex = "<"
66 elif self.sex == chr(ELFFile.ELFDATA2MSB): 66 elif self.sex == chr(ELFFile.ELFDATA2MSB):
67 self.sex = ">" 67 self.sex = ">"
68 else: 68 else:
69 raise Exception("Unknown self.sex") 69 raise ValueError("Unknown self.sex")
70 70
71 def osAbi(self): 71 def osAbi(self):
72 return ord(self.data[ELFFile.EI_OSABI]) 72 return ord(self.data[ELFFile.EI_OSABI])
@@ -80,7 +80,7 @@ class ELFFile:
80 def isLittleEndian(self): 80 def isLittleEndian(self):
81 return self.sex == "<" 81 return self.sex == "<"
82 82
83 def isBigEngian(self): 83 def isBigEndian(self):
84 return self.sex == ">" 84 return self.sex == ">"
85 85
86 def machine(self): 86 def machine(self):