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