hostprogs-y += test_overhead
 hostprogs-y += test_cgrp2_array_pin
 hostprogs-y += test_cgrp2_attach
-hostprogs-y += test_cgrp2_attach2
 hostprogs-y += test_cgrp2_sock
 hostprogs-y += test_cgrp2_sock2
 hostprogs-y += xdp1
 test_overhead-objs := bpf_load.o test_overhead_user.o
 test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o
 test_cgrp2_attach-objs := test_cgrp2_attach.o
-test_cgrp2_attach2-objs := test_cgrp2_attach2.o $(CGROUP_HELPERS)
 test_cgrp2_sock-objs := test_cgrp2_sock.o
 test_cgrp2_sock2-objs := bpf_load.o test_cgrp2_sock2.o
 xdp1-objs := xdp1_user.o
 
        test_sock test_btf test_sockmap test_lirc_mode2_user get_cgroup_id_user \
        test_socket_cookie test_cgroup_storage test_select_reuseport test_section_names \
        test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
-       test_btf_dump
+       test_btf_dump test_cgroup_attach
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
 TEST_GEN_FILES = $(BPF_OBJ_FILES)
 $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
+$(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
 
 .PHONY: force
 
 
+// SPDX-License-Identifier: GPL-2.0
+
 /* eBPF example program:
  *
  * - Creates arraymap in kernel with 4 bytes keys and 8 byte values
 #include <sys/resource.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <linux/filter.h>
 
 #include <linux/bpf.h>
 #include <bpf/bpf.h>
 
-#include "bpf_insn.h"
+#include "bpf_util.h"
 #include "bpf_rlimit.h"
 #include "cgroup_helpers.h"
 
 #define FOO            "/foo"
 #define BAR            "/foo/bar/"
-#define PING_CMD       "ping -c1 -w1 127.0.0.1 > /dev/null"
+#define PING_CMD       "ping -q -c1 -w1 127.0.0.1 > /dev/null"
 
 char bpf_log_buf[BPF_LOG_BUF_SIZE];
 
+#ifdef DEBUG
+#define debug(args...) printf(args)
+#else
+#define debug(args...)
+#endif
+
 static int prog_load(int verdict)
 {
        int ret;
                goto err;
        }
 
-       printf("Attached DROP prog. This ping in cgroup /foo should fail...\n");
+       debug("Attached DROP prog. This ping in cgroup /foo should fail...\n");
        assert(system(PING_CMD) != 0);
 
        /* Create cgroup /foo/bar, get fd, and join it */
        if (join_cgroup(BAR))
                goto err;
 
-       printf("Attached DROP prog. This ping in cgroup /foo/bar should fail...\n");
+       debug("Attached DROP prog. This ping in cgroup /foo/bar should fail...\n");
        assert(system(PING_CMD) != 0);
 
        if (bpf_prog_attach(allow_prog, bar, BPF_CGROUP_INET_EGRESS,
                goto err;
        }
 
-       printf("Attached PASS prog. This ping in cgroup /foo/bar should pass...\n");
+       debug("Attached PASS prog. This ping in cgroup /foo/bar should pass...\n");
        assert(system(PING_CMD) == 0);
 
        if (bpf_prog_detach(bar, BPF_CGROUP_INET_EGRESS)) {
                goto err;
        }
 
-       printf("Detached PASS from /foo/bar while DROP is attached to /foo.\n"
+       debug("Detached PASS from /foo/bar while DROP is attached to /foo.\n"
               "This ping in cgroup /foo/bar should fail...\n");
        assert(system(PING_CMD) != 0);
 
                goto err;
        }
 
-       printf("Attached PASS from /foo/bar and detached DROP from /foo.\n"
+       debug("Attached PASS from /foo/bar and detached DROP from /foo.\n"
               "This ping in cgroup /foo/bar should pass...\n");
        assert(system(PING_CMD) == 0);
 
        close(bar);
        cleanup_cgroup_environment();
        if (!rc)
-               printf("### override:PASS\n");
+               printf("#override:PASS\n");
        else
-               printf("### override:FAIL\n");
+               printf("#override:FAIL\n");
        return rc;
 }
 
        close(cg5);
        cleanup_cgroup_environment();
        if (!rc)
-               printf("### multi:PASS\n");
+               printf("#multi:PASS\n");
        else
-               printf("### multi:FAIL\n");
+               printf("#multi:FAIL\n");
        return rc;
 }
 
-int main(int argc, char **argv)
+int main(void)
 {
-       int rc = 0;
+       int (*tests[])(void) = {test_foo_bar, test_multiprog};
+       int errors = 0;
+       int i;
 
-       rc = test_foo_bar();
-       if (rc)
-               return rc;
+       for (i = 0; i < ARRAY_SIZE(tests); i++)
+               if (tests[i]())
+                       errors++;
+
+       if (errors)
+               printf("test_cgroup_attach:FAIL\n");
+       else
+               printf("test_cgroup_attach:PASS\n");
 
-       return test_multiprog();
+       return errors ? EXIT_FAILURE : EXIT_SUCCESS;
 }