\subsection*{Introduction}

Libraries need a pervasive testing for continuous improvement. Any problem found and behaviour described must be written down as test and integrated so that after running all tests in the build directory\+: \begin{DoxyVerb}make run_all
\end{DoxyVerb}


and on the target (installed) system\+: \begin{DoxyVerb}kdb run_all
\end{DoxyVerb}


assures that all these promises hold.

To run memcheck tests use\+: \begin{DoxyVerb}make run_memcheck
\end{DoxyVerb}


In the build directory, internally ctest is used, so you can also call ctest with its options. On the target (installed) system our own scripts drive the tests.

\subsection*{Conventions}


\begin{DoxyItemize}
\item All names of the test must start with test
\item No tests should run if E\+N\+A\+B\+L\+E\+\_\+\+T\+E\+S\+T\+I\+N\+G is O\+F\+F.
\item All tests that access harddisc\+:
\begin{DoxyItemize}
\item should be tagged with kdbtests
\item should not shall run, if E\+N\+A\+B\+L\+E\+\_\+\+K\+D\+B\+\_\+\+T\+E\+S\+T\+I\+N\+G is O\+F\+F.
\item should only write below /tests ans system/mountpoints
\end{DoxyItemize}
\item If your test has memleaks, e.\+g. because the library used leaks and that cannot be fixed, give them the label memleak with following command\+:

set\+\_\+property(\+T\+E\+S\+T testname P\+R\+O\+P\+E\+R\+T\+Y L\+A\+B\+E\+L\+S memleak)
\end{DoxyItemize}

\subsection*{Strategy}

The testing must happen on every level of the software to achieve a maximum coverage with the available time. In the rest of the document we describe the different levels and where these tests are.

\subsubsection*{C\+Framework}

This is basically a bunch of assertion macros and some output facilities. It is written in pure C and very lightweight.

It is located here.

\subsubsection*{A\+B\+I Tests}

C A\+B\+I Tests are written in plain C with the help of cframework.

The main purpose of these tests are, that the binaries of old versions can be used against new versions as A\+B\+I tests.

So lets say we compile Elektra 0.\+8.\+8 (at this version dedicated A\+B\+I tests were introduced) in the -\/full variant. But when we run the tests, we use libelektra-\/full.\+so.\+0.\+8.\+9 (either by installing it or by setting L\+D\+\_\+\+L\+I\+B\+R\+A\+R\+Y\+\_\+\+P\+A\+T\+H). You can check with ldd which version is used.

The tests are located here.

\subsubsection*{C Unit Tests}

C Unit Tests are written in plain C with the help of cframework.

It is used to test internal data structures of libelektra that are not A\+B\+I relevant.

A\+B\+I tests can be done on theses tests, too. But by nature from time to time these tests will fail.

They are located here.

\subsubsection*{Module Tests}

The modules, which are typically used as plugins in Elektra (but can also be available statically or in the -\/full variant), should have their own tests.

Use the Cmake macro add\+\_\+plugintest for adding these tests.

\subsubsection*{C++ Unit Tests}

C++ Unit tests are done using the gtest framework. See \hyperlink{doc_decisions_unit_testing_md}{architectural decision}.

Use the C\+Make macro add\+\_\+gtest for adding these tests.

\subsubsection*{Script Tests}

Script test are done using P\+O\+S\+I\+X shell + C\+Make. See \hyperlink{doc_decisions_script_testing_md}{architectural decision}.

The script tests have different purposes\+:
\begin{DoxyItemize}
\item End to End tests (usage of tools as a user would do)
\item External Compilation tests (compile and run programs as a user would do)
\item Conventions tests (do internal checks that check for common problems)
\item Meta Test Suites (run other test suites)
\end{DoxyItemize}

\subsubsection*{Other kind of Tests}

Bindings, other than C++ typically have their own way of testing.

\subsection*{Fuzz Testing}

copy some import files to testcase\+\_\+dir and run\+:

/usr/src/afl/afl-\/1.46b/./afl-\/fuzz -\/i testcase\+\_\+dir -\/o findings\+\_\+dir bin/kdb import user/tests 