summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2019-03-19 14:52:29 +0100
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2019-03-22 12:53:01 +0000
commit5c4b9f1efd1c5d9853a3c508e2a103d0f5679173 (patch)
treec99cd1497c254979c78c025f078dde505a7ca95f /src
parentf7f13347bc8bc941a2d9aa847ddd88a758d65f71 (diff)
vppapigen: allow for enum size other than u32
Change-Id: If20d2fbab9b854b7db276c81918fdff6abcb8385 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py11
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py8
2 files changed, 15 insertions, 4 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index e189b024454..6c4ca356f3a 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -127,10 +127,19 @@ def typedefs(objs, aliases, filename):
tname = o.__class__.__name__
output += duplicate_wrapper_head(o.name)
if tname == 'Enum':
- output += "typedef enum {\n"
+ if o.enumtype == 'u32':
+ output += "typedef enum {\n"
+ else:
+ output += "typedef enum __attribute__((__packed__)) {\n"
+
for b in o.block:
output += " %s = %s,\n" % (b[0], b[1])
output += '} vl_api_%s_t;\n' % o.name
+ if o.enumtype != 'u32':
+ size1 = 'sizeof(vl_api_%s_t)' % o.name
+ size2 = 'sizeof(%s)' % o.enumtype
+ err_str = 'size of API enum %s is wrong' % o.name
+ output += 'STATIC_ASSERT(%s == %s, "%s");\n' % (size1, size2, err_str)
else:
if tname == 'Union':
output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index 1e59e366a8f..bd5f050bba9 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -279,11 +279,13 @@ class VLAList_legacy():
class VPPEnumType(object):
def __init__(self, name, msgdef):
self.size = types['u32'].size
+ self.enumtype = 'u32'
e_hash = {}
for f in msgdef:
if type(f) is dict and 'enumtype' in f:
if f['enumtype'] != 'u32':
- raise NotImplementedError
+ self.size = types[f['enumtype']].size
+ self.enumtype = f['enumtype']
continue
ename, evalue = f
e_hash[ename] = evalue
@@ -297,10 +299,10 @@ class VPPEnumType(object):
return True
def pack(self, data, kwargs=None):
- return types['u32'].pack(data)
+ return types[self.enumtype].pack(data)
def unpack(self, data, offset=0, result=None, ntc=False):
- x, size = types['u32'].unpack(data, offset)
+ x, size = types[self.enumtype].unpack(data, offset)
return self.enum(x), size
d='n76' href='#n76'>76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
#!/bin/bash
# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -x

# Space separated list of available testbeds, described by topology files
TOPOLOGIES="topologies/available/lf_testbed1.yaml \
            topologies/available/lf_testbed2.yaml \
            topologies/available/lf_testbed3.yaml"

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Reservation dir
RESERVATION_DIR="/tmp/reservation_dir"

PYBOT_ARGS="-W 150"

ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)

# we will download the DPDK in the robot

WORKING_TOPOLOGY=""
export PYTHONPATH=${SCRIPT_DIR}

sudo apt-get -y update
sudo apt-get -y install libpython2.7-dev python-virtualenv

virtualenv --system-site-packages env
. env/bin/activate

echo pip install
pip install -r requirements.txt

# We iterate over available topologies and wait until we reserve topology
while :; do
    for TOPOLOGY in ${TOPOLOGIES};
    do
        python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
        if [ $? -eq 0 ]; then
            WORKING_TOPOLOGY=${TOPOLOGY}
            echo "Reserved: ${WORKING_TOPOLOGY}"
            break
        fi
    done

    if [ ! -z "${WORKING_TOPOLOGY}" ]; then
        # Exit the infinite while loop if we made a reservation
        break
    fi

    # Wait ~3minutes before next try
    SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
    echo "Sleeping ${SLEEP_TIME}"
    sleep ${SLEEP_TIME}
done

#for DPDK test, we don't need to install the VPP deb
function cancel_all {
    python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
}

# On script exit we cancel the reservation
trap "cancel_all ${WORKING_TOPOLOGY}" EXIT

case "$TEST_TAG" in
    # run specific performance tests based on jenkins job type variable
    PERFTEST_LONG )
        pybot ${PYBOT_ARGS} \
              -L TRACE \
              -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
              -v DPDK_TEST:True \
              -s "dpdk-tests.perf" \
              --exclude SKIP_PATCH \
              -i NDRPDRDISC \
              dpdk-tests/
        RETURN_STATUS=$(echo $?)
        ;;
    PERFTEST_SHORT )
        pybot ${PYBOT_ARGS} \
              -L TRACE \
              -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
              -v DPDK_TEST:True \
              -s "dpdk-tests.perf" \
              -i NDRCHK \
              dpdk-tests/
        RETURN_STATUS=$(echo $?)
        ;;
   PERFTEST_NIGHTLY )
        #run all available tests
        pybot ${PYBOT_ARGS} \
              -L TRACE \
              -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
              -v DPDK_TEST:True \
              -s "dpdk-tests.perf" \
              dpdk-tests/
        RETURN_STATUS=$(echo $?)
        ;;
    * )
        # run full performance test suite and exit on fail
        pybot ${PYBOT_ARGS} \
              -L TRACE \
              -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
              -v DPDK_TEST:True \
              -s "dpdk-tests.perf" \
              dpdk-tests/
        RETURN_STATUS=$(echo $?)
esac

# Pybot output post-processing
echo Post-processing test data...

python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
       -i ${SCRIPT_DIR}/output.xml \
       -o ${SCRIPT_DIR}/output_perf_data.xml
if [ ! $? -eq 0 ]; then
    echo "Parsing ${SCRIPT_DIR}/output.xml failed"
fi

# Archive artifacts
mkdir archive
for i in ${ARCHIVE_ARTIFACTS[@]}; do
    cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
done

echo Post-processing finished.

exit ${RETURN_STATUS}