simple script(s) to check if bsearch tables are sorted correctly
This commit is contained in:
12
.github/checks/Makefile
vendored
12
.github/checks/Makefile
vendored
@@ -5,14 +5,18 @@ endif
|
|||||||
|
|
||||||
ifdef CMD_EXE
|
ifdef CMD_EXE
|
||||||
|
|
||||||
.PHONY: checkstyle
|
.PHONY: checkstyle sorted
|
||||||
|
|
||||||
checkstyle:
|
checkstyle:
|
||||||
$(info INFO: style checks require bash.)
|
$(info INFO: style checks require bash.)
|
||||||
|
sorted:
|
||||||
|
$(info INFO: table checks require bash.)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
.PHONY: checkstyle lineendings tabs lastline spaces noexec
|
.PHONY: checkstyle lineendings tabs lastline spaces noexec sorted
|
||||||
|
|
||||||
|
all: checkstyle sorted
|
||||||
|
|
||||||
checkstyle: lineendings tabs lastline spaces noexec
|
checkstyle: lineendings tabs lastline spaces noexec
|
||||||
|
|
||||||
@@ -31,4 +35,8 @@ spaces: spaces.sh
|
|||||||
noexec: noexec.sh
|
noexec: noexec.sh
|
||||||
@./noexec.sh
|
@./noexec.sh
|
||||||
|
|
||||||
|
sorted: sorted.sh sorted_codeopt.sh
|
||||||
|
@./sorted.sh
|
||||||
|
@./sorted_codeopt.sh
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
117
.github/checks/sorted.sh
vendored
Executable file
117
.github/checks/sorted.sh
vendored
Executable file
@@ -0,0 +1,117 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
OLDCWD=`pwd`
|
||||||
|
SCRIPT_PATH=`dirname $0`
|
||||||
|
|
||||||
|
SORT_OPT=-u
|
||||||
|
|
||||||
|
function checkarray_quoted_name
|
||||||
|
{
|
||||||
|
CHECK_FILE="$1"
|
||||||
|
|
||||||
|
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||||
|
sed -e 's:.*\"\(.*\)\".*:\1:g' | \
|
||||||
|
sed '/^\s*$/d' > .a.tmp
|
||||||
|
|
||||||
|
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||||
|
echo "error: "$2" table is empty"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||||
|
|
||||||
|
if cmp --silent -- .a.tmp .b.tmp; then
|
||||||
|
echo ""$2" definitions OK"
|
||||||
|
else
|
||||||
|
echo "error: "$2" definitions are not sorted."
|
||||||
|
diff -y .a.tmp .b.tmp
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
rm -rf .a.tmp .b.tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkinstr_quoted_name
|
||||||
|
{
|
||||||
|
CHECK_FILE="$1"
|
||||||
|
|
||||||
|
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||||
|
sed -e 's:^ *{$::g' | \
|
||||||
|
sed -e 's:^ *}$::g' | \
|
||||||
|
sed -e 's:.*\"\(.*\)\".*:\1:g' | \
|
||||||
|
sed '/^\s*$/d' > .a.tmp
|
||||||
|
|
||||||
|
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||||
|
echo "error: "$2" table is empty"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||||
|
|
||||||
|
if cmp --silent -- .a.tmp .b.tmp; then
|
||||||
|
echo ""$2" definitions OK"
|
||||||
|
else
|
||||||
|
echo "error: "$2" definitions are not sorted."
|
||||||
|
diff -y .a.tmp .b.tmp
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
rm -rf .a.tmp .b.tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkopcodes_quoted_name
|
||||||
|
{
|
||||||
|
CHECK_FILE="$1"
|
||||||
|
|
||||||
|
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||||
|
grep "^ *\".*\"," | \
|
||||||
|
sed '/^\s*$/d' > .a.tmp
|
||||||
|
|
||||||
|
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||||
|
echo "error: "$2" table is empty"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||||
|
|
||||||
|
if cmp --silent -- .a.tmp .b.tmp; then
|
||||||
|
echo ""$2" definitions OK"
|
||||||
|
else
|
||||||
|
echo "error: "$2" definitions are not sorted."
|
||||||
|
diff -y .a.tmp .b.tmp
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
rm -rf .a.tmp .b.tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502\.Ins\) \/ sizeof \(InsTab6502\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502X\.Ins\) \/ sizeof \(InsTab6502X\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502DTV\.Ins\) \/ sizeof \(InsTab6502DTV\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65C02\.Ins\) \/ sizeof \(InsTab65C02\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab4510\.Ins\) \/ sizeof \(InsTab4510\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65816\.Ins\) \/ sizeof \(InsTab65816\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabSweet16\.Ins\) \/ sizeof \(InsTabSweet16\.Ins\[0\]\),"
|
||||||
|
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabHuC6280\.Ins\) \/ sizeof \(InsTabHuC6280\.Ins\[0\]\),"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/ca65/scanner.c "} DotKeywords \[\] = {"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/cc65/codeinfo.c "static const FuncInfo FuncInfoTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/cc65/codeinfo.c "static const ZPInfo ZPInfoTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/cc65/codeoptutil.c "static const char\* const Tab\[\]"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncRegATable\[\]"
|
||||||
|
|
||||||
|
checkopcodes_quoted_name ../../src/cc65/opcodes.c "const OPCDesc OPCTable\[OP65_COUNT\] = {"
|
||||||
|
checkarray_quoted_name ../../src/cc65/pragma.c "} Pragmas\[\] = {"
|
||||||
|
checkarray_quoted_name ../../src/cc65/preproc.c "} PPDTypes\[\] = {"
|
||||||
|
checkarray_quoted_name ../../src/cc65/scanner.c "} Keywords \[\] = {"
|
||||||
|
checkarray_quoted_name ../../src/cc65/stdfunc.c "} StdFuncs\[\] = {"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/common/filetype.c "static const FileId TypeTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/common/target.c "static const TargetEntry TargetMap\[\]"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/dbginfo/dbginfo.c "} KeywordTable\[\] = {"
|
||||||
|
|
||||||
|
checkarray_quoted_name ../../src/sp65/convert.c "static const ConverterMapEntry ConverterMap\[\]"
|
||||||
|
checkarray_quoted_name ../../src/sp65/input.c "static const FileId FormatTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/sp65/output.c "static const FileId FormatTable\[\]"
|
||||||
|
checkarray_quoted_name ../../src/sp65/palconv.c "static const PaletteMapEntry PaletteMap\[\]"
|
||||||
|
|
||||||
42
.github/checks/sorted_codeopt.sh
vendored
Executable file
42
.github/checks/sorted_codeopt.sh
vendored
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
OLDCWD=`pwd`
|
||||||
|
SCRIPT_PATH=`dirname $0`
|
||||||
|
CHECK_FILE=../../src/cc65/codeopt.c
|
||||||
|
|
||||||
|
SORT_OPT=-u
|
||||||
|
|
||||||
|
grep "^static OptFunc " $CHECK_FILE | \
|
||||||
|
sed -e 's:.*"\(.*\)",.*:\1:g' > .a.tmp
|
||||||
|
|
||||||
|
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||||
|
echo "error: OptFunc table is empty"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||||
|
|
||||||
|
if cmp --silent -- .a.tmp .b.tmp; then
|
||||||
|
echo "static OptFunc definitions OK"
|
||||||
|
else
|
||||||
|
echo "error: static OptFunc definitions are not sorted."
|
||||||
|
diff -y .a.tmp .b.tmp
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
awk '/static OptFunc\* OptFuncs\[\] = {/{flag=1;next}/}/{flag=0}flag' $CHECK_FILE | \
|
||||||
|
sed -e 's:.*&D\(.*\),:\1:g' > .a.tmp
|
||||||
|
|
||||||
|
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||||
|
echo "error: OptFuncs table is empty"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if cmp --silent -- .a.tmp .b.tmp; then
|
||||||
|
echo "static OptFuncs* OptFuncs[] definitions OK"
|
||||||
|
else
|
||||||
|
echo "error: static OptFuncs* OptFuncs[] definitions are not sorted."
|
||||||
|
diff -y .a.tmp .b.tmp
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf .a.tmp .b.tmp
|
||||||
1
Makefile
1
Makefile
@@ -50,6 +50,7 @@ test:
|
|||||||
# GNU "check" target, which runs all tests
|
# GNU "check" target, which runs all tests
|
||||||
check:
|
check:
|
||||||
@$(MAKE) -C .github/checks checkstyle --no-print-directory
|
@$(MAKE) -C .github/checks checkstyle --no-print-directory
|
||||||
|
@$(MAKE) -C .github/checks sorted --no-print-directory
|
||||||
@$(MAKE) test
|
@$(MAKE) test
|
||||||
@$(MAKE) -C targettest platforms --no-print-directory
|
@$(MAKE) -C targettest platforms --no-print-directory
|
||||||
@$(MAKE) -C samples platforms --no-print-directory
|
@$(MAKE) -C samples platforms --no-print-directory
|
||||||
|
|||||||
Reference in New Issue
Block a user