1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# The per-function checksums klp checksum records are what klp diff uses to 5# decide which functions changed. A checksum covering too little misses a real 6# change and the patch silently omits the function; one covering too much, or 7# unstable across identical input, clones functions nobody patched and drags 8# their dependencies in with them. 9# 10# test-basic covers which functions got cloned, which is downstream of this and 11# passes for either kind of wrong checksum as long as the two errors do not 12# happen to cancel. This checks the checksums themselves. 13 14. "$(dirname "$0")/../lib.sh" 15 16setup 17build_pair basic.c 18 19assert_input_symbol changed 20assert_input_symbol untouched 21 22run_checksum 23 24# The edited function's checksum has to move, the untouched one's must not. 25assert_checksum_differs changed 26assert_checksum_matches untouched 27 28# And it has to be a function of the code, not of the build: checksumming the 29# same input twice has to give the same answer, or every rebuild reports 30# spurious changes. 31first="$(checksum_of orig.o changed)" 32build_pair basic.c 33run_checksum 34[ "$(checksum_of orig.o changed)" = "$first" ] || 35 fail "checksum for 'changed' differs between builds of identical source" 36 37pass "checksums track the changed function and are stable across rebuilds" 38