Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90e75dc9 authored by Martin Geisler's avatar Martin Geisler Committed by Gerrit Code Review
Browse files

Merge changes Iafa74463,I9701f2a9,I9715a489,Ia0c4e004,Ic8519e3b, ...

* changes:
  pdl: Add canonical tests for variable sized arrays
  pdl: Add canonical tests for body fields
  pdl: Add more byte element canonical tests
  pdl: Reorder canonical test files
  pdl: Derive big-endian test files automatically
  pdl: Add Packet_Reserved_Field canonical test
parents d4197147 18c94565
Loading
Loading
Loading
Loading
+37 −4
Original line number Diff line number Diff line
@@ -124,6 +124,39 @@ genrule_defaults {
    ],
}

// The generators support more features for LE packets than for BE
// packets. We use a single input written for LE packets and remove
// the parts that don't work for BE packets. We do this by removing
// everything between
//
// // Start: little_endian_only
//
// and
//
// // End: little_endian_only
//
// from the LE packet input.
genrule_defaults {
    name: "pdl_be_test_file_defaults",
    cmd: "sed -e 's/little_endian_packets/big_endian_packets/' " +
        "     -e '/Start: little_endian_only/,/End: little_endian_only/d' " +
        " < $(in) > $(out)",
}

genrule {
    name: "pdl_be_rust_test_file",
    defaults: ["pdl_be_test_file_defaults"],
    srcs: ["tests/canonical/le_rust_test_file.pdl"],
    out: ["be_rust_test_file.pdl"],
}

genrule {
    name: "pdl_be_test_file",
    defaults: ["pdl_be_test_file_defaults"],
    srcs: ["tests/canonical/le_test_file.pdl"],
    out: ["be_test_file.pdl"],
}

// Generate the Rust parser+serializer backends.
genrule {
    name: "pdl_le_backend",
@@ -135,7 +168,7 @@ genrule {
genrule {
    name: "pdl_be_backend",
    defaults: ["pdl_rust_generator_defaults"],
    srcs: ["tests/canonical/be_rust_test_file.pdl"],
    srcs: [":pdl_be_rust_test_file"],
    out: ["be_backend.rs"],
}

@@ -269,8 +302,8 @@ genrule {
    ],
}

// Generate the python parser+serializer backend for the
// big endian test file located at tests/canonical/be_test_file.pdl.
// Generate the python parser+serializer backend for a big endian test
// file derived from tests/canonical/le_test_file.pdl.
genrule {
    name: "pdl_python_generator_be_test_gen",
    defaults: ["pdl_python_generator_defaults"],
@@ -282,7 +315,7 @@ genrule {
        "tests/custom_types.py",
    ],
    srcs: [
        "tests/canonical/be_test_file.pdl",
        ":pdl_be_test_file",
    ],
    out: [
        "be_pdl_test.py",
+20 −8
Original line number Diff line number Diff line
@@ -136,34 +136,46 @@ fn main() {
    generate_unit_tests(
        &input_path,
        &[
            "Packet_Scalar_Field",
            "Packet_Enum_Field",
            "Packet_Enum8_Field",
            "EnumChild_A",
            "EnumChild_B",
            "Packet_Array_Field_ByteElement_ConstantSize",
            "Packet_Array_Field_ByteElement_UnknownSize",
            "Packet_Array_Field_ByteElement_VariableCount",
            "Packet_Array_Field_ByteElement_VariableSize",
            "Packet_Array_Field_EnumElement",
            "Packet_Array_Field_EnumElement_ConstantSize",
            "Packet_Array_Field_EnumElement_UnknownSize",
            "Packet_Array_Field_EnumElement_VariableCount",
            "Packet_Array_Field_EnumElement_VariableCount",
            "Packet_Array_Field_ScalarElement",
            "Packet_Array_Field_ScalarElement_ConstantSize",
            "Packet_Array_Field_ScalarElement_UnknownSize",
            "Packet_Array_Field_ScalarElement_VariableCount",
            "Packet_Array_Field_ScalarElement_VariableSize",
            "Packet_Array_Field_SizedElement_ConstantSize",
            "Packet_Array_Field_SizedElement_UnknownSize",
            "Packet_Array_Field_SizedElement_VariableCount",
            "Packet_Array_Field_SizedElement_VariableSize",
            "Packet_Array_Field_UnsizedElement_ConstantSize",
            "Packet_Array_Field_UnsizedElement_UnknownSize",
            "Packet_Array_Field_UnsizedElement_VariableCount",
            "Packet_Array_Field_UnsizedElement_VariableSize",
            "Packet_Size_Field",
            "Packet_Body_Field_UnknownSize",
            "Packet_Body_Field_UnknownSize_Terminal",
            "Packet_Body_Field_VariableSize",
            "Packet_Count_Field",
            "Packet_FixedScalar_Field",
            "Packet_Enum8_Field",
            "Packet_Enum_Field",
            "Packet_FixedEnum_Field",
            "Packet_Payload_Field_VariableSize",
            "Packet_FixedScalar_Field",
            "Packet_Payload_Field_UnknownSize",
            "Packet_Payload_Field_UnknownSize_Terminal",
            "Packet_Payload_Field_VariableSize",
            "Packet_Reserved_Field",
            "Packet_Scalar_Field",
            "Packet_Size_Field",
            "ScalarChild_A",
            "ScalarChild_B",
            "EnumChild_A",
            "EnumChild_B",
        ],
        &module_name,
    );
+0 −206
Original line number Diff line number Diff line
big_endian_packets

// Preliminary definitions

enum Enum7 : 7 {
    A = 1,
    B = 2,
}

enum Enum16 : 16 {
    A = 0xaabb,
    B = 0xccdd,
}

struct SizedStruct {
    a: 8,
}

struct UnsizedStruct {
    _size_(array): 2,
    _reserved_: 6,
    array: 8[],
}

enum MaxDiscriminantEnum : 64 {
     Max = 0xffffffffffffffff,
}

// Packet bit fields

// The parser must be able to handle bit fields with scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Scalar_Field {
    a: 7,
    c: 57,
}

// The parser must be able to handle bit fields with enum values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Enum_Field {
    a: Enum7,
    c: 57,
}

// Array fields
// Array element types

// The parser must be able to handle bit fields with size fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Size_Field {
    _size_(b): 3,
    a: 61,
    b: 8[],
}


// The parser must be able to handle bit fields with count fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Count_Field {
    _count_(b): 3,
    a: 61,
    b: 8[],
}

// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_FixedScalar_Field {
    _fixed_ = 7 : 7,
    b: 57,
}

// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
packet Packet_FixedEnum_Field {
    _fixed_ = A : Enum7,
    b: 57,
}

packet Packet_Array_Field_ByteElement_ConstantSize {
    array: 8[4],
}

packet Packet_Array_Field_ByteElement_UnknownSize {
    array: 8[],
}

packet Packet_Array_Field_ScalarElement_ConstantSize {
    array: 16[4],
}

packet Packet_Array_Field_ScalarElement_UnknownSize {
    array: 16[],
}

packet Packet_Array_Field_EnumElement_ConstantSize {
    array: Enum16[4],
}

packet Packet_Array_Field_EnumElement_UnknownSize {
    array: Enum16[],
}

packet Packet_Array_Field_SizedElement_ConstantSize {
    array: SizedStruct[4],
}

packet Packet_Array_Field_SizedElement_UnknownSize {
    array: SizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_ConstantSize {
    array: UnsizedStruct[4],
}

packet Packet_Array_Field_UnsizedElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_UnknownSize {
    array: UnsizedStruct[],
}

// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_FixedScalar_Field_ {
    _fixed_ = 7 : 7,
    b: 57,
}

// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
struct Struct_FixedEnum_Field_ {
    _fixed_ = A : Enum7,
    b: 57,
}

packet ScalarParent {
    a: 8,
    _size_(_payload_): 8,
    _payload_
}

packet EnumParent {
    a: Enum16,
    _size_(_payload_): 8,
    _payload_
}

// Packet inheritance

// The parser must handle specialization into
// any child packet of a parent packet with scalar constraints.
packet ScalarChild_A : ScalarParent (a = 0) {
    b: 8,
}

// The parser must handle specialization into
// any child packet of a parent packet with scalar constraints.
packet ScalarChild_B : ScalarParent (a = 1) {
    c: 16,
}

// The parser must handle specialization into
// any child packet of a parent packet with enum constraints.
packet EnumChild_A : EnumParent (a = A) {
    b: 8,
}

// The parser must handle specialization into
// any child packet of a parent packet with enum constraints.
packet EnumChild_B : EnumParent (a = B) {
    c: 16,
}

// Packet payload fields

// The parser must be able to handle sized payload fields without
// size modifier.
packet Packet_Payload_Field_VariableSize {
    _size_(_payload_): 3,
    _reserved_: 5,
    _payload_
}

// The parser must be able to handle payload fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Payload_Field_UnknownSize {
    _payload_,
    a: 16,
}

// The parser must be able to handle payload fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Payload_Field_UnknownSize_Terminal {
    a: 16,
    _payload_,
}
+0 −736

File deleted.

Preview size limit exceeded, changes collapsed.

+129 −52
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@ little_endian_packets

// Preliminary definitions

enum MaxDiscriminantEnum : 64 {
     Max = 0xffffffffffffffff,
}

enum Enum7 : 7 {
    A = 1,
    B = 2,
@@ -22,8 +26,16 @@ struct UnsizedStruct {
    array: 8[],
}

enum MaxDiscriminantEnum : 64 {
     Max = 0xffffffffffffffff,
packet ScalarParent {
    a: 8,
    _size_(_payload_): 8,
    _payload_
}

packet EnumParent {
    a: Enum16,
    _size_(_payload_): 8,
    _payload_
}

// Packet bit fields
@@ -42,8 +54,13 @@ packet Packet_Enum_Field {
    c: 57,
}

// Array fields
// Array element types
// The parser must be able to handle bit fields with reserved fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Reserved_Field {
    a: 7,
    _reserved_: 2,
    c: 55,
}

// The parser must be able to handle bit fields with size fields
// up to 64 bits wide.  The parser should generate a static size guard.
@@ -53,7 +70,6 @@ packet Packet_Size_Field {
    b: 8[],
}


// The parser must be able to handle bit fields with count fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Count_Field {
@@ -76,10 +92,72 @@ packet Packet_FixedEnum_Field {
    b: 57,
}

// Packet payload fields

// The parser must be able to handle sized payload fields without
// size modifier.
packet Packet_Payload_Field_VariableSize {
    _size_(_payload_): 3,
    _reserved_: 5,
    _payload_
}

// The parser must be able to handle payload fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Payload_Field_UnknownSize {
    _payload_,
    a: 16,
}

// The parser must be able to handle payload fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Payload_Field_UnknownSize_Terminal {
    a: 16,
    _payload_,
}

// Packet body fields

// The parser must be able to handle sized body fields without
// size modifier when the packet has no children.
packet Packet_Body_Field_VariableSize {
    _size_(_body_): 3,
    _reserved_: 5,
    _body_
}

// The parser must be able to handle body fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Body_Field_UnknownSize {
    _body_,
    a: 16,
}

// The parser must be able to handle body fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Body_Field_UnknownSize_Terminal {
    a: 16,
    _body_,
}

packet Packet_Array_Field_ByteElement_ConstantSize {
    array: 8[4],
}

packet Packet_Array_Field_ByteElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: 8[],
}

packet Packet_Array_Field_ByteElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: 8[],
}

packet Packet_Array_Field_ByteElement_UnknownSize {
    array: 8[],
}
@@ -88,6 +166,18 @@ packet Packet_Array_Field_ScalarElement_ConstantSize {
    array: 16[4],
}

packet Packet_Array_Field_ScalarElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: 16[],
}

packet Packet_Array_Field_ScalarElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: 16[],
}

packet Packet_Array_Field_ScalarElement_UnknownSize {
    array: 16[],
}
@@ -96,6 +186,18 @@ packet Packet_Array_Field_EnumElement_ConstantSize {
    array: Enum16[4],
}

packet Packet_Array_Field_EnumElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}

packet Packet_Array_Field_EnumElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}

packet Packet_Array_Field_EnumElement_UnknownSize {
    array: Enum16[],
}
@@ -104,6 +206,18 @@ packet Packet_Array_Field_SizedElement_ConstantSize {
    array: SizedStruct[4],
}

packet Packet_Array_Field_SizedElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}

packet Packet_Array_Field_SizedElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}

packet Packet_Array_Field_SizedElement_UnknownSize {
    array: SizedStruct[],
}
@@ -128,32 +242,6 @@ packet Packet_Array_Field_UnsizedElement_UnknownSize {
    array: UnsizedStruct[],
}

// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_FixedScalar_Field_ {
    _fixed_ = 7 : 7,
    b: 57,
}

// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
struct Struct_FixedEnum_Field_ {
    _fixed_ = A : Enum7,
    b: 57,
}

packet ScalarParent {
    a: 8,
    _size_(_payload_): 8,
    _payload_
}

packet EnumParent {
    a: Enum16,
    _size_(_payload_): 8,
    _payload_
}

// Packet inheritance

// The parser must handle specialization into
@@ -180,27 +268,16 @@ packet EnumChild_B : EnumParent (a = B) {
    c: 16,
}

// Packet payload fields

// The parser must be able to handle sized payload fields without
// size modifier.
packet Packet_Payload_Field_VariableSize {
    _size_(_payload_): 3,
    _reserved_: 5,
    _payload_
}

// The parser must be able to handle payload fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Payload_Field_UnknownSize {
    _payload_,
    a: 16,
// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_FixedScalar_Field_ {
    _fixed_ = 7 : 7,
    b: 57,
}

// The parser must be able to handle payload fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Payload_Field_UnknownSize_Terminal {
    a: 16,
    _payload_,
// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
struct Struct_FixedEnum_Field_ {
    _fixed_ = A : Enum7,
    b: 57,
}
Loading