2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-01-27 15:37:10 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-04-02 20:51:44 +03:00
set -eu
2021-04-20 14:02:02 +03:00
set -o pipefail
2018-11-28 06:50:04 +03:00
2021-04-02 20:51:44 +03:00
SOURCE_ROOT = " ${ 1 : ?Missing argument : project source root } "
BUILD_ROOT = " ${ 2 : ?Missing argument : project build root } "
command -v gawk & >/dev/null || exit 77
2019-05-07 21:46:36 +03:00
2018-11-28 06:50:04 +03:00
function generate_directives( ) {
2021-04-02 20:51:44 +03:00
gawk -v sec_rx = " ${ 2 :- "" } " -v unit_type = " ${ 3 :- "" } " '
match( $0 , /^( [ ^ \t \. ] +) \. ( [ ^ \t \. ,] +) /, m) {
# res[section][directive] = 1
res[ m[ 1] ] [ m[ 2] ] = 1;
}
END {
if ( unit_type)
print unit_type
for ( section in res) {
if ( sec_rx && section !~ sec_rx)
continue
print "[" section "]" ;
for ( directive in res[ section] ) {
print directive "=" ;
}
}
}
' " $1 "
2018-11-28 06:50:04 +03:00
}
2019-02-22 12:00:54 +03:00
ret = 0
2019-05-07 21:31:32 +03:00
if ! diff \
2021-04-02 20:51:44 +03:00
<( generate_directives " $SOURCE_ROOT " /src/network/networkd-network-gperf.gperf | sort) \
<( sort " $SOURCE_ROOT " /test/fuzz/fuzz-network-parser/directives.network) ; then
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo "Looks like test/fuzz/fuzz-network-parser/directives.network hasn't been updated"
ret = 1
2018-11-28 06:50:04 +03:00
fi
2019-05-07 21:31:32 +03:00
if ! diff \
2021-04-02 20:51:44 +03:00
<( generate_directives " $SOURCE_ROOT " /src/network/netdev/netdev-gperf.gperf | sort) \
<( sort " $SOURCE_ROOT " /test/fuzz/fuzz-netdev-parser/directives.netdev) ; then
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo "Looks like test/fuzz/fuzz-netdev-parser/directives.netdev hasn't been updated"
ret = 1
2018-11-28 06:50:04 +03:00
fi
2019-02-22 08:47:36 +03:00
2019-05-07 21:31:32 +03:00
if ! diff \
2021-04-02 20:51:44 +03:00
<( generate_directives " $SOURCE_ROOT " /src/udev/net/link-config-gperf.gperf | sort) \
<( sort " $SOURCE_ROOT " /test/fuzz/fuzz-link-parser/directives.link) ; then
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo "Looks like test/fuzz/fuzz-link-parser/directives.link hasn't been updated"
ret = 1
2019-02-22 08:47:36 +03:00
fi
2019-02-22 12:00:54 +03:00
2021-04-02 20:51:44 +03:00
for section in Automount Mount Path Scope Slice Socket Swap Timer; do
if ! diff \
<( generate_directives " $BUILD_ROOT " /src/core/load-fragment-gperf.gperf " $section " " ${ section ,, } " | sort) \
<( sort " $SOURCE_ROOT /test/fuzz/fuzz-unit-file/directives. ${ section ,, } " ) ; then
echo " Looks like test/fuzz/fuzz-unit-file/directives. ${ section ,, } hasn't been updated "
ret = 1
fi
done
if ! diff \
<( generate_directives " $BUILD_ROOT " /src/core/load-fragment-gperf.gperf "(Service|Unit|Install)" "service" | sort) \
<( sort " $SOURCE_ROOT /test/fuzz/fuzz-unit-file/directives.service " ) ; then
echo "Looks like test/fuzz/fuzz-unit-file/directives.service hasn't been updated"
ret = 1
fi
2019-02-22 12:00:54 +03:00
exit $ret