#!/bin/bash

# openSUSE Tumbleweed x86_64 Kconfig
curl https://raw.githubusercontent.com/SUSE/kernel-source/refs/heads/stable/config/x86_64/default > .config
scripts/config --file .config --set-str MODULE_SIG_KEY "certs/signing_key.pem"
make olddefconfig
make mod2noconfig

# v7.3-rc5
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1

#  CLNG-BPF [test_progs] lsm_cgroup.bpf.o
#progs/lsm_cgroup.c:107:21: error: variable has incomplete type 'struct sockaddr_ll'
scripts/config --file .config --enable PACKET
make olddefconfig
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1

#  CLNG-BPF [test_progs] test_bpf_nf.bpf.o
#progs/test_bpf_nf.c:89:49: error: declaration of 'union nf_inet_addr' will not be visible outside of this function [-Werror,-Wvisibility]
#progs/test_bpf_nf.c:195:22: error: variable has incomplete type 'union nf_inet_addr'
#progs/test_bpf_nf.c:200:5: error: incomplete definition of type 'struct nf_conn'
#progs/test_bpf_nf.c:233:12: error: use of undeclared identifier 'IPS_CONFIRMED'
#progs/test_bpf_nf.c:233:28: error: use of undeclared identifier 'IPS_SEEN_REPLY'
scripts/config --file .config -e NF_CONNTRACK -e NF_NAT
make olddefconfig
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1

#  CLNG-BPF [test_progs] test_bpf_nf.bpf.o
#progs/test_bpf_nf.c:200:7: error: no member named 'mark' in 'struct nf_conn'
scripts/config --file .config -e NF_CONNTRACK_MARK
make olddefconfig
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1

#  CLNG-BPF [test_progs] test_lwt_ip_encap.bpf.o
#progs/test_lwt_ip_encap.c:105:19: error: field has incomplete type 'struct vxlanhdr'
scripts/config --file .config -e VXLAN
make olddefconfig
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1

#  CLNG-BPF [test_progs] test_tunnel_kern.bpf.o
#progs/test_tunnel_kern.c:45:51: error: declaration of 'struct bpf_xfrm_state_opts' will not be visible outside of this function [-Werror,-Wvisibility]
#progs/test_tunnel_kern.c:964:24: error: variable has incomplete type 'struct bpf_xfrm_state'
#progs/test_tunnel_kern.c:983:29: error: variable has incomplete type 'struct bpf_xfrm_state_opts'
scripts/config --file .config -e XFRM_USER
make olddefconfig
make -j
make -C tools/testing/selftests SKIP_TARGETS= TARGETS=bpf FORCE_TARGETS=1
