Date:        Wed, 26 Nov 2025 20:40:04 +0100
    From:        Nemanja Simonovic <[email protected]>
    Message-ID:  <[email protected]>

  | I am stuck trying to create new ATF test case. Hitting "Unexpected token
  | `<<EOF>>'; expected a header name" but can't figure out where error is.

You have two problems I can see at a glance.

  | Content of testa -------------------------------------------------------
  |
  | #!/bin/sh

That needs to be:

        #! /usr/bin/atf-sh
  |
  | atf_test_case testa

Or commands like that one won't exist,

  | testa_head(){
  |          atf_set "descr" "Test for ATF tests"
  | }
  |
  | testa_body(){
  |          atf_check -s eq:1 -o empty -e empty test -d a
  |          atf_check -s eq:0 -o empty -e empty mkdir a
  |          atf_check -s eq:0 -o empty -e empty test -d a
  | }

And you need a definition of the function atf_init_test_cases
which should be something like (for your case)

atf_init_test_cases() {
        atf_add_test_case testa
}

That would gain extra lines as more test cases are added to the test.
Traditionally it is placed last in the test source file.

There are LOTS of ATF tests around to look at, were I you, I'd go sample
several of them, to see how they are set up - there are many ways that the
tests can operate, which suit different needs, seeing how some of them are
achieved might save you lots of time long term.   Look in /usr/src/tests
and if you don't have that, at least the sh script types of tests are
viewable in /usr/tests (the ones that use compiled binaries are less useful
from there).

kre


Reply via email to