Skip to content

Commit 87239fe

Browse files
committed
Abstract conflicts and dependencies examples
1 parent e52118d commit 87239fe

File tree

2 files changed

+164
-11
lines changed

2 files changed

+164
-11
lines changed

chapters/generating-tests.tex

Lines changed: 164 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
\chapter{Construction of Occurrence Graph Grammars}\label{ch:tests}
1+
\chapter{Construction of Occurrence Graph Grammars with NACs}\label{ch:tests}
22

33
%A test case is a collection of (1) input values necessary to complete some execution of the system under testing, (2) the results that must be produced after executing the test (assuming the system satisfies the intended behaviour) and (3) any inputs necessary to setup the system into the appropriate state to receive the test values~\cite{Ammann2008}.
44
%Test oracles are specifications describing properties about the validity of tests cases, i.e. if the test must fail or pass. These properties may include relationships between the input given and the expected output, data validity properties, format of possible execution paths, etc. No matter the oracle format, it must be able to determine the validity of tests in a finite and reasonable amount of time~\cite{Weyuker1982}.
@@ -295,19 +295,115 @@ \section{Constructing the OGG}
295295
%\end{figure}
296296
%\fi
297297

298+
In our previous example, no situation with abstract conflicts or dependencies was found.
299+
This grammar and the particular execution chosen have a causal relation which forces a sequencing of actions that avoids the existence of abstract conflicts/dependencies.
300+
In our case studies, this situation has show to be very common in graph grammars extracted from use cases, where there are clear steps that must be followed in a specific order to accomplish the completion of a functionality.
301+
Nonetheless, in graph grammars that model systems with higher parallelism or concurrency, situations with abstract conflicts/dependencies have shown to arise more often. We now introduce another graph grammar example to illustrate the construction of an occurrence graph grammar with NACs which has a non-empty set of restrictions.
302+
303+
\begin{example} Figure~\ref{fig:tests:grammar-traffic} depicts a graph grammar that models a common traffic situation, where a pedestrian cross a street. This grammar has only three rules, which are summarized as:
304+
305+
\begin{enumerate}[label=(\alph*),start=2]
306+
\item \emph{walk:} a pedestrian is on a sidewalk and crosses the street to be on another sidewalk, however he/she can not do so if there is a closed traffic light.
307+
\item \emph{open:} turns a closed traffic light into an open one.
308+
\item \emph{close:} turns an open traffic light into a closed one.
309+
\end{enumerate}
310+
\end{example}
311+
312+
\begin{figure}[!ht]
313+
\centering
314+
\begin{subfigure}[t]{.5\textwidth}
315+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/type-graph}}}
316+
\caption{Type Graph of the Grammar}\label{fig:tests:traffic-type-graph}
317+
\end{subfigure}
318+
\begin{subfigure}[t]{.5\textwidth}
319+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/walk}}}
320+
\caption{Rule \emph{walk}}
321+
\end{subfigure}
322+
\begin{subfigure}[t]{.5\textwidth}
323+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/open}}}
324+
\caption{Rule \emph{open}}
325+
\end{subfigure}%
326+
\begin{subfigure}[t]{.5\textwidth}
327+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/close}}}
328+
\caption{Rule \emph{close}}
329+
\end{subfigure}
330+
\caption{Graph Grammar of the Traffic System}\label{fig:tests:grammar-traffic}
331+
\end{figure}
332+
333+
As before, to begin the construction of the occurrence graph grammar with NACs for our graph grammar, we will need a collection of rules and an input-output relation. The collection chosen consists of one copy of each rule in the original grammar. The $IO$ relation is also very simple and it only identifies the traffic lights and the edges that represent they are closed in rules \emph{close} and \emph{open}. The relation is depicted on Figure~\ref{fig:tests:inout-traffic}.
334+
335+
\begin{figure}[!ht]
336+
\centering
337+
\fbox{\includegraphics[scale=0.5]{grammar/traffic/io}}
338+
\caption{Input output relation for the traffic graph grammar}\label{fig:tests:inout-traffic}
339+
\end{figure}
340+
341+
The first step, the amalgamation of rules, results in the core graph depicted in Figure~\ref{fig:tests:amalgamation-traffic}. Notice that, differently from the type graph in Figure~\ref{fig:tests:traffic-type-graph}, it has concrete elements, a generic pedestrian is now \emph{Jane}, there are two specific sidewalks which are connected by the \emph{Avenue B}, etc.
342+
343+
\begin{figure}[!ht]
344+
\centering
345+
\fbox{\includegraphics[scale=0.5]{grammar/traffic/amalgamation}}
346+
\caption{Amalgamation (colimit) of rules for the traffic grammar example.}\label{fig:tests:amalgamation-traffic}
347+
\end{figure}
348+
349+
The retyping of rules provides the actions depicted in Figure~\ref{fig:tests:actions-traffic}. Once again, NACs are not shown due to limitations with AGG format compatibility for double-typed graph grammars.
350+
351+
The causal relation for this execution of the grammar consists of the set represented only by the pair \emph{close} $<$ \emph{open}. Therefore, in this context, the traffic light must be closed before it opens and, so far, the action \emph{walk} does not relate to any of the others. This relation is a partial order, given that there are multiple options of total orderings which respect this relation: $[walk < close < open]$, $[close < walk < open]$ and $[close < open < walk]$.
352+
353+
\begin{figure}[!ht]
354+
\centering
355+
\begin{subfigure}[t]{.5\textwidth}
356+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/amalgamation/walk}}}
357+
\caption{Action \emph{walk}}
358+
\end{subfigure}
359+
\begin{subfigure}[t]{.5\textwidth}
360+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/server/amalgamation/getData}}}
361+
\caption{Action \emph{open}}
362+
\end{subfigure}
363+
\begin{subfigure}[t]{.5\textwidth}
364+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/server/amalgamation/receiveMsg}}}
365+
\caption{Action \emph{close}}
366+
\end{subfigure}
367+
\caption{The set of actions generated for the traffic graph grammar.}\label{fig:tests:actions-traffic}
368+
\end{figure}
369+
370+
The \emph{Initial} and \emph{Final} graphs obtained by deletion of elements created (resp. deleted) by the actions in the core graph are shown in Figure~\ref{fig:tests:graphs-traffic}.
371+
372+
\begin{figure}[!ht]
373+
\centering
374+
\begin{subfigure}[t]{.5\textwidth}
375+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/init}}}
376+
\caption{Initial graph}
377+
\end{subfigure}%
378+
\begin{subfigure}[t]{.5\textwidth}
379+
\centerline{\fbox{\includegraphics[scale=0.5]{grammar/traffic/final}}}
380+
\caption{Final graph}
381+
\end{subfigure}
382+
\caption{Instance graphs for the traffic grammar}\label{fig:tests:graphs-traffic}
383+
\end{figure}
384+
385+
The categorization of conflicts and dependencies is where the behaviour of this graph grammar defers from our previous example.
386+
There is one potential produce-forbid conflict between actions \emph{close} and \emph{walk} and one potential delete-forbid dependency between actions \emph{open} and \emph{walk}.
387+
Both the conflict and the dependency act over the same triggering element, the \emph{closed} edge in the NAC of action \emph{walk}.
388+
This element is not present in the \emph{Initial} graph, as it is created by the action \emph{close}.
389+
Also, the element is not (causally) related to the action \emph{walk}, given that the actions which create and delete it are themselves not related to that action.
390+
It is easy to see that the action \emph{walk} can either occur before action \emph{close} or after action \emph{open}, but never in between them, because \emph{Jane} must not cross \emph{Avenue B} while the traffic light is closed.
391+
Therefore, we have an abstract produce-forbid conflict as well as an abstract delete-forbid dependency which, in this case, are both denoted by the tuple $(walk,close, open)$. Moreover, as there are no concrete conflicts and dependencies induced by NACs the occurrence relation remains equal to the causal relation.
392+
393+
Finally, we have to find at least one total ordering of the actions respecting both the occurrence relation $\leq_o$ = $[close <_o open]$ and the set of occurrence relation restrictions $R = (walk,close,open)$. In fact, there are two such orderings: $[walk < close < open]$ and $[close < open < walk]$. Therefore, the strongly safe graph grammar constructed from this graph grammar execution is also an occurrence graph grammar with NACs.
394+
298395
\section{Generating Tests}
299396

300397
%Once the previous verifications were executed, we can build the occurrence relation to verify whether $OGG_i$ can be really an occurrence graph grammar. If no abstract dependencies or conflicts are found, then the concrete relations are sufficient to perform this verification, and it suffices to check if there is a total ordering compatible with the occurrence relation. If the set $R$ of \emph{occurrence relation restrictions} is not empty, we also need to check if there is a total ordering of the occurrence relation that respects these restrictions.
301398

302399
%As to check wether a partial order satisfies the generated set of restrictions seems to be a hard problem, in the complexity sense, we left this last implementation as a future work.
303400

304-
Occurrence Graph Grammars may be used to generate a set of tests for a Graph Grammar. In our case studies, no situation with abstract conflicts or dependencies was found. We believe that it happens because we used grammars extracted from real use cases, where usually there are (possibly many) sequential connections between the actions, which forces the rules to be connected via the \emph{occurrence relation} and avoids abstract restrictions.
305-
306-
The process of constructing an occurrence graph grammar may provide insights for tests even when it fails. In the case where OGGs are found, we have test cases for successful executions of the system and conditions over how the system should execute. In the case where OGGs are not found, we have test cases for executions where the system must always fail.
401+
Occurrence Graph Grammars may be used to generate a set of tests for a Graph Grammar. The process of constructing an occurrence graph grammar may provide insights for tests even when it fails. In the case where OGGs are found, we have test cases for successful executions of the system under modelling and conditions over how the system should execute. In the case where OGGs are not found, we have test cases for executions where the system must always fail.
307402

308403
We use the occurrence relation and the set of abstract restrictions as test oracles, to define the acceptance of the tests: any path that complies to the format imposed by them is considered valid and must always succeed. On the other hand, paths that break at least one of such restrictions are considered invalid, and their tests must always capture them as failures.
309404

310-
The tests are represented by the concrete orderings of the rules execution, orderings of elements creation/deletion, and by the initial and final graphs. The ordering of rules is one of (possibly) many valid orders in which the rules can be applied according to the occurrence relation. The ordering of elements represent an ordering in which the state of the system may be constructed. While the initial and final graphs translate the valid formats for the input and output of each test. More specific usability details can be found on the Verigraph tutorial, which can be found at \url{https://github.com/Verites/verigraph-tutorial/releases}.
405+
The tests are represented by the concrete orderings of the rules execution, orderings of elements creation/deletion, and by the initial and final graphs.
406+
An ordering of rules is one of (possibly) many valid orders in which the rules can be applied according to the occurrence relation. An ordering of elements represents an ordering in which the state of the system may be constructed. While the initial and final graphs translate the valid/necessary data for the input and output of each test. More specific usability details can be found on the Verigraph tutorial, which can be found at \url{https://github.com/Verites/verigraph-tutorial/releases}.
311407

312408

313409
The output of Verigraph for an OGG creation and its test case generation is shown on Figure~\ref{fig:tests:checklist}. On the first figure, Verigraph performs the basic verifications to check whether the generated output is, in fact, an occurrence grammar.
@@ -321,14 +417,71 @@ \section{Generating Tests}
321417
[OK] Final graph is valid
322418
[OK] Concrete occurrence relation is a total order
323419
[OK] Concrete elements relation is a total order
324-
[OK] There are no abstract restrictions
325-
Analysis written in tmp/output_analysis
326-
Test cases written in tmp/output_test_cases
327-
Doubly-typed grammar saved in tmp/output.ggx
420+
[WARN] There are abstract restrictions
421+
Analysis written in ogg_execution_analysis
422+
Test cases written in ogg_execution_test_cases
423+
Doubly-typed grammar saved in ogg_execution.ggx
328424
\end{minted}
329425
\label{fig:tests:checklist}
330426
\end{figure}
331427

332-
The analysis file contains the results for calculation of conflicts and dependencies among rules and among elements. The test cases file contains the information relevant to test designer.
333-
The \code{.ggx} presents the occurrence graph grammar constructed\footnote{ AGG supports its visualization only as a simply-typed graph grammar.}, together with its initial and final graphs.
428+
The analysis file contains a summary of the results for calculation of conflicts and dependencies among rules and among elements. For example: which conflicts and dependencies were found; for the conflicts and dependencies induced by NACs which are the triggering elements of each NAC; the causal relation between elements and actions that created/deleted them, etc. Figure~\ref{fig:tests:analysis} depicts the content of the analysis file for our traffic example.
429+
430+
\begin{figure}[!ht]
431+
\caption{Analysis file content}
432+
\begin{minted}[linenos=true, breaklines,fontsize=\small]{shell}
433+
Conflicts and Dependencies:
434+
[
435+
Interaction {firstRule = "close", secondRule = "walk", interactionType = ProduceForbid, nacInvolved = Just 0},
436+
Interaction {firstRule = "close", secondRule = "open", interactionType = ProduceUse, nacInvolved = Nothing},
437+
Interaction {firstRule = "open", secondRule = "walk", interactionType = DeleteForbid, nacInvolved = Just 0}
438+
]
439+
440+
Creation and Deletion Relation:
441+
[
442+
(Edge 1,Rule "open"),(Edge 4,Rule "walk"),(Rule "close",Edge 1),(Rule "walk",Edge 7)
443+
]
444+
445+
Conflicts and dependencies induced by NACs:
446+
[
447+
(Interaction {firstRule = "close", secondRule = "walk", interactionType = ProduceForbid, nacInvolved = Just 0},Edge 1),
448+
(Interaction {firstRule = "open", secondRule = "walk", interactionType = DeleteForbid, nacInvolved = Just 0},Edge 1)
449+
]
450+
\end{minted}
451+
\label{fig:tests:analysis}
452+
\end{figure}
453+
454+
455+
The test cases file contains information we consider relevant to a test designer, such as the rules and elements involved in that particular execution of the graph grammar represented by the occurrence graph grammar, as well as the occurrence relation, a total ordering of rules application (if found) and the set of restrictions (if found). Figure~\ref{fig:tests:cases} presents the content of the test cases files for our traffic example.
456+
457+
458+
\begin{figure}[!ht]
459+
\caption{Test cases file content}
460+
\begin{minted}[linenos=true, breaklines,fontsize=\small]{shell}
461+
Rules involved:
462+
[Rule "close",Rule "open",Rule "walk"]
463+
464+
Concrete Rules Relation:
465+
[(Rule "close" < Rule "open")]
466+
467+
Elements involved:
468+
[Node 1,Node 7,Node 8,Node 9,Edge 1,Edge 3,Edge 4,Edge 7]
469+
470+
Elements Relation:
471+
[(Edge 4 < Edge 7)]
472+
473+
Rules Ordering: Just [Rule "close",Rule "open",Rule "walk"]
474+
475+
Elements Ordering: Just [Node 1,Node 7,Node 8,Node 9,Edge 1,Edge 3,Edge 4,Edge 7]
476+
477+
Set of Abstract Restrictions:
478+
[
479+
(AbstractProduceForbid: Rule "walk" must not occur between [Rule "close" < Rule "open"]),
480+
(AbstractDeleteForbid: Rule "walk" must not occur between [Rule "close" < Rule "open"])
481+
]
482+
\end{minted}
483+
\label{fig:tests:cases}
484+
\end{figure}
485+
486+
Finally, the \code{.ggx} file presents a translation of the constructed occurrence graph grammar from Verigraph format to AGG format in order to support the OGG graphical visualization. It contains its actions (without NACs), initial and final graphs and core graph (which assumes the role of the type-graph in AGG) as shown in the previous section.
334487

grammar/traffic/type-graph.png

5.83 KB
Loading

0 commit comments

Comments
 (0)