# ATF

# FAQ

# How to build a test suite?

cc -L/usr/local/lib -latf-c test.c -o test

# How to add a new test case?

ATF_TC(my_new_test_case);

# How to define metadata in test case?

atf_tc_set_md_var(tc, "descr", "my description");

# How to put some assertion in a test case?

ATF_TC_BODY(my_new_test_case, tc) {
    ATF_CHECK(0 == 0+0);
    ATF_CHECK_EQ(0, 0 + 0);
    ATF_CHECK_EQ_MSG(0, 0+1, "my error message");
}      

# How to execute a test case?

ATF_TP_ADD_TCS(tp) {
    ATF_TP_ADD_TC(tp, my_new_test_case);
    return atf_no_error();
}

# How to run atf?

You need to create kyuafile (see https://www.freebsd.org/cgi/man.cgi?query=kyuafile), and just execute:

kyua test

# References and Resources

  • http://netbsd.gw.com/cgi-bin/man-cgi?atf+7+NetBSD-current
  • https://wiki.netbsd.org/tutorials/atf/