def testLengthZero(self):
     with self.assertRaises(KittyException):
         BitField(value=self.default_value, length=0)
 def testLengthVerySmall(self):
     self._base_check(BitField(value=1, length=1))
Esempio n. 3
0
        LE16(name='wFormatTag', value=0x0001)
    ])


# TODO: remove?
audio_as_format_type_descriptor = Descriptor(
    name='audio_as_format_type_descriptor',
    descriptor_type=DescriptorType.cs_interface,
    fields=[
        UInt8(name='bDesciptorSubType', value=_AS_DescriptorSubTypes.FORMAT_TYPE),
        UInt8(name='bFormatType', value=0x01),
        UInt8(name='bNrChannels', value=0x01),
        UInt8(name='bSubFrameSize', value=0x02),
        UInt8(name='bBitResolution', value=0x10),
        UInt8(name='bSamFreqType', value=0x01),
        BitField(name='tSamFreq', length=24, value=0x01F40)
    ])


audio_hid_descriptor = Descriptor(
    name='audio_hid_descriptor',
    descriptor_type=DescriptorType.hid,
    fields=[
        DynamicInt('bcdHID', LE16(value=0x1001)),
        DynamicInt('bCountryCode', UInt8(value=0x00)),
        DynamicInt('bNumDescriptors', UInt8(value=0x01)),
        DynamicInt('bDescriptorType2', UInt8(value=DescriptorType.hid)),
        DynamicInt('wDescriptorLength', LE16(value=0x2b)),
    ]
)
 def testLengthNegative(self):
     with self.assertRaises(KittyException):
         BitField(value=self.default_value, length=-1)
 def testLengthVeryLarge(self):
     for full_range in[True, False]:
         field = BitField(value=1, length=1)
         self._base_check(field)
 def testValueNegative(self):
     for full_range in[True, False]:
         self._base_check(BitField(value=-50, length=7, signed=True, full_range=full_range))
 def testLengthTooSmallForValueUnsigned(self):
     for full_range in[True, False]:
         with self.assertRaises(KittyException):
             BitField(value=64, length=6, signed=False, full_range=full_range)
Esempio n. 8
0
 def __init__(self, name, version=0x00, flags=0x0000000, fields=[], fuzzable=True):
     super(Mp4FullBox, self).__init__(name, fields=[
         BE8(name="version", value=version),
         BitField(name="flags", value=flags, length=24, encoder=ENC_INT_BE),
     ] + fields, fuzzable=fuzzable)
Esempio n. 9
0
 def setUp(self, cls=SizeInBytes, length=32):
     super(SizeInBytesTest, self).setUp(cls)
     self.bit_field = BitField(value=0, length=length)
     self.length = length
Esempio n. 10
0
 def testLengthVerySmall(self):
     for full_range in[True, False]:
         self._base_check(BitField(value=1, length=1, full_range=full_range))
Esempio n. 11
0
 def setUp(self, cls=IndexOf):
     super(IndexOfTestCase, self).setUp(cls)
     self.length = 32
     self.bit_field = BitField(value=0, length=self.length)
Esempio n. 12
0
 def setUp(self, cls=ElementCount):
     super(ElementCountTests, self).setUp(cls)
     self.length = 32
     self.bit_field = BitField(value=0, length=self.length)
Esempio n. 13
0
File: cdc.py Progetto: xairy/nu-map
 name='Class-Specific interfaces',
 fields=[
     SubDescriptor(name='cdc_header_functional_descriptor',
                   descriptor_type=DescriptorType.cs_interface,
                   fields=[
                       UInt8(name='bDesciptorSubType',
                             value=FunctionalDescriptor.Header),
                       LE16(name='bcdCDC', value=0x0101)
                   ]),
     SubDescriptor(name='cdc_call_management_functional_descriptor',
                   descriptor_type=DescriptorType.cs_interface,
                   fields=[
                       UInt8(name='bDesciptorSubType',
                             value=FunctionalDescriptor.CM),
                       BitField(name='bmCapabilities',
                                value=0,
                                length=8),
                       UInt8(name='bDataInterface', value=2)
                   ]),
     SubDescriptor(
         name=
         'cdc_abstract_control_management_functional_descriptor',
         descriptor_type=DescriptorType.cs_interface,
         fields=[
             UInt8(name='bDesciptorSubType',
                   value=FunctionalDescriptor.ACM),
             BitField(name='bmCapabilities', value=0, length=8)
         ]),
     SubDescriptor(name='cdc_union_functional_descriptor',
                   descriptor_type=DescriptorType.cs_interface,
                   fields=[
 def testLengthTooSmallForValueUnsigned(self):
     with self.assertRaises(KittyException):
         BitField(value=64, length=6, signed=False)
Esempio n. 15
0
 def testLengthTooSmallForMaxValue(self):
     for full_range in[True, False]:
         with self.assertRaises(KittyException):
             BitField(value=10, length=5, signed=True, max_value=17, full_range=full_range)
 def testLengthTooSmallForMaxValue(self):
     with self.assertRaises(KittyException):
         BitField(value=10, length=5, signed=True, max_value=17)
Esempio n. 17
0
# Configuration descriptor
# Section 9.6.3, page 265
configuration_descriptor = Template(
    name='configuration_descriptor',
    fields=[
        UInt8(name='bLength', value=9),
        UInt8(name='bDescriptorType', value=DescriptorType.configuration),
        SizeInBytes(name='wTotalLength',
                    sized_field='/',
                    length=16,
                    encoder=ENC_INT_LE),
        ElementCount(name='bNumInterfaces', depends_on='interfaces', length=8),
        UInt8(name='bConfigurationValue', value=1),
        UInt8(name='iConfiguration', value=0),
        BitField(name='bmAttributes', value=0, length=8),
        UInt8(name='bMaxPower', value=1),
        List(name='interfaces',
             fields=[
                 Container(
                     name='iface and eps',
                     fields=[
                         SubDescriptor(
                             name='interface_descriptor',
                             descriptor_type=DescriptorType.interface,
                             fields=[
                                 UInt8(name='bInterfaceNumber', value=0),
                                 UInt8(name='bAlternateSetting', value=0),
                                 ElementCount(name='bNumEndpoints',
                                              depends_on='endpoints',
                                              length=8),