thesis: Start Chapter 3
This commit is contained in:
@@ -1,21 +1,73 @@
|
||||
|
||||
\chapter{Manipulating Function Calls}\label{ch:manipulating-function-calls}
|
||||
|
||||
Lorem Ipsum.
|
||||
This chapter discusses how to manipulate function calls and how this may be used to test programs.
|
||||
For how function calls may be intercepted at all, see Chapter~\ref{ch:intercepting-function-calls}.
|
||||
This chapter builds on the basis of the previous one and expands its functions.
|
||||
``Manipulation'' in this context means to change the arguments of a function then running it normally, or skipping the execution of the real function completely and simply returning a given value (``mocking'').
|
||||
These techniques allow in-depth testing of programs.
|
||||
|
||||
In contrast to simply recording and logging function calls which may be controlled via environment variables, manipulation of such function calls requires some other process to indicate how to handle each call.
|
||||
This work uses simple sockets to communicate between the process of the program to be tested and a ``server'' which decides what action to perform for each function call.
|
||||
Currently, only communication over Unix sockets is implemented, but communication over TCP sockets is also easily possible.
|
||||
|
||||
Figure~\ref{fig:control-flow} illustrates the control flow for manipulating function calls.
|
||||
|
||||
\begin{figure}
|
||||
\begin{sequencediagram}
|
||||
\newthread{p}{:Program}
|
||||
\newinst{l}{:\texttt{\textit{lib}.so}}
|
||||
\newinst{i}{:\texttt{intercept.so}}
|
||||
\newthreadShift[gray]{s}{:Server}{2cm}
|
||||
|
||||
%\begin{sdblock}{Normal Call}{}
|
||||
% \begin{call}{p}{read()}{l}{return a}
|
||||
% \end{call}
|
||||
%\end{sdblock}
|
||||
|
||||
\begin{sdblock}{Intercepted Call}{}
|
||||
\begin{call}{p}{malloc(x)}{i}{return a}
|
||||
\mess{i}{{``malloc(x)''}}{s}
|
||||
\mess{s}{``ok''}{i}
|
||||
\begin{call}{i}{malloc(x)}{l}{return a}
|
||||
\end{call}
|
||||
\mess{i}{``return a''}{s}
|
||||
\end{call}
|
||||
\end{sdblock}
|
||||
|
||||
\begin{sdblock}{Manipulated Call}{}
|
||||
\begin{call}{p}{malloc(x)}{i}{return a}
|
||||
\mess{i}{{``malloc(x)''}}{s}
|
||||
\mess{s}{``modify y''}{i}
|
||||
\begin{call}{i}{malloc(y)}{l}{return a}
|
||||
\end{call}
|
||||
\mess{i}{``return a''}{s}
|
||||
\end{call}
|
||||
\end{sdblock}
|
||||
|
||||
\begin{sdblock}{Mocked Call}{}
|
||||
\begin{call}{p}{malloc(x)}{i}{return z}
|
||||
\mess{i}{{``malloc(x)''}}{s}
|
||||
\mess{s}{``fail'' / ``return z''}{i}
|
||||
\mess{i}{``return z''}{s}
|
||||
\end{call}
|
||||
\end{sdblock}
|
||||
\end{sequencediagram}
|
||||
\centering
|
||||
\caption{Simplified Control Flow for Function Call Manipulation.}
|
||||
\label{fig:control-flow}
|
||||
\end{figure}
|
||||
|
||||
Unix-Sockets, TCP-Sockets, \dots
|
||||
|
||||
\section{Defining a Protocol}\label{sec:defining-a-protocol}
|
||||
|
||||
Lorem Ipsum.
|
||||
|
||||
|
||||
\section{Parsing Responses}\label{sec:parsing-responses}
|
||||
|
||||
Lorem Ipsum.
|
||||
|
||||
\section{Creating a Socket Server in Python}\label{sec:creating-a-socket-server-in-python}
|
||||
|
||||
Lorem Ipsum.
|
||||
|
||||
\section{Automated Testing using Function Call Manipulation}\label{sec:automated-testing-using-function-call-manipulation}
|
||||
|
||||
|
||||
@@ -40,6 +40,15 @@
|
||||
\usepackage{minted}
|
||||
\usepackage{chngcntr}
|
||||
\counterwithin{listing}{chapter}
|
||||
\usepackage{pgf-umlsd}
|
||||
|
||||
\newcommand{\newthreadShift}[4][gray!30]{
|
||||
\newinst[#4]{#2}{#3}
|
||||
\stepcounter{threadnum}
|
||||
\node[below of=inst\theinstnum,node distance=0.8cm] (thread\thethreadnum) {};
|
||||
\tikzstyle{threadcolor\thethreadnum}=[fill=#1]
|
||||
\tikzstyle{instcolor#2}=[fill=#1]
|
||||
}
|
||||
|
||||
% Set PDF document properties
|
||||
\hypersetup{
|
||||
|
||||
Reference in New Issue
Block a user