#!/bin/bash

# Project Calico BPF dataplane build scripts.
# Copyright (c) 2020-2021 Tigera, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

# Generate filenames of UT-only programs; in particular ones that force-set the packet mark to
# some known values.
#
# WARNING: should be kept in sync with the combinations used in tests, in particular bpf_prog_test.go.

emit_filename() {
  echo "bin/test_${from_or_to}_${ep_type}_fib_${log_level}${dsr}.o"
  echo "bin/test_${from_or_to}_${ep_type}_fib_${log_level}${dsr}_v6.o"
}

log_level=debug
ep_types="wep hep nat"
for ep_type in $ep_types; do
  directions="from to"
  for from_or_to in $directions; do
    for dsr in "" "_dsr"; do
      if [ "${dsr}" = "_dsr" ]; then
        if [ "${ep_type}" = "hep" ]; then
          emit_filename
          continue
        fi
        if [ "${from_or_to}" = "from" ] && [ "${ep_type}" = "wep" ]; then
          emit_filename
          continue
        fi
      else
        emit_filename
      fi
    done
  done
done

echo "bin/test_from_hep_fib_no_log_skb0x0.o"
echo "bin/test_from_wep_fib_no_log.o"
echo "bin/test_xdp_debug.o"
echo "bin/test_xdp_debug_co-re_v6.o"
