Statistics
| Branch: | Revision:

root / scripts / check-qerror.sh @ 2a2af967

History | View | Annotate | Download (635 Bytes)

1 9737383b Stefan Hajnoczi
#!/bin/sh
2 9737383b Stefan Hajnoczi
# This script verifies that qerror definitions and table entries are
3 9737383b Stefan Hajnoczi
# alphabetically ordered.
4 9737383b Stefan Hajnoczi
5 9737383b Stefan Hajnoczi
check_order() {
6 9737383b Stefan Hajnoczi
  errmsg=$1
7 9737383b Stefan Hajnoczi
  shift
8 9737383b Stefan Hajnoczi
9 9737383b Stefan Hajnoczi
  # sort -C verifies order but does not print a message.  sort -c does print a
10 9737383b Stefan Hajnoczi
  # message.  These options are both in POSIX.
11 9737383b Stefan Hajnoczi
  if ! "$@" | sort -C; then
12 9737383b Stefan Hajnoczi
    echo "$errmsg"
13 9737383b Stefan Hajnoczi
    "$@" | sort -c
14 9737383b Stefan Hajnoczi
    exit 1
15 9737383b Stefan Hajnoczi
  fi
16 9737383b Stefan Hajnoczi
  return 0
17 9737383b Stefan Hajnoczi
}
18 9737383b Stefan Hajnoczi
19 9737383b Stefan Hajnoczi
check_order 'Definitions in qerror.h must be in alphabetical order:' \
20 9737383b Stefan Hajnoczi
            grep '^#define QERR_' qerror.h
21 9737383b Stefan Hajnoczi
check_order 'Entries in qerror.c:qerror_table must be in alphabetical order:' \
22 9737383b Stefan Hajnoczi
            sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c