search.noResults

search.searching

saml.title
dataCollection.invalidEmail
note.createNoteMessage

search.noResults

search.searching

orderForm.title

orderForm.productCode
orderForm.description
orderForm.quantity
orderForm.itemPrice
orderForm.price
orderForm.totalPrice
orderForm.deliveryDetails.billingAddress
orderForm.deliveryDetails.deliveryAddress
orderForm.noItems
Feature: Tools


SuperGuard provides full traceability for requirements-based testing. To provide evidence of completeness, it offers nearly 100% structural code coverage for more than 80% of functions, with high modified- condition/decision-coverage (MC/DC).


An example Each SuperGuard library test is developed according to a consistent methodology. Tis is the specification in Section 7.21.2.4 of the C99 language definition:


7.21.2.4 Te strncpy function Synopsis 1


this description, considering what the function should actually do. Tese are: REQ-copystring: If s2 points to a string


with a length ‘l2’ (as defined by strlen()) that is less than n, strncpy() shall copy l2 characters, in order, from the array s2 into the array s1. REQ-copyn: If s2 does not point to a


string with length less than n, strncpy() shall copy the first n characters, in order, from the array s2 into the array s1. REQ-shorter: If s2 points to a string


#include <string.h> char * strncpy(char * restrict s1, const char * restrict s2, size_t n); Description


2


Te strncpy function copies not more than n characters (characters that follow a null character are not copied) from the array pointed to by s2 to the array pointed to by s1. If copying takes place between objects that overlap, the behaviour is undefined.


3


If the array pointed to by s2 is a string shorter than n characters, null characters are appended to the copy in the array pointed to by s1, until n characters in all have been written. Returns


4


Te strncpy function returns the value of s1.


Te key point here is that Paragraph 2 specifies what strncpy() does not do. It reads: “copies not more than n characters”. Nowhere does it require that any characters are copied from s2 to s1. In Paragraph 3 it states an action, namely that s1 is padded with null characters. A literarily correct implementation according to this would be to write n null characters to s1. However, this is not what the function


should do. Te general understanding is that the function copies as many characters as possible from s2 to s1 until either the string s2 or n is exhausted. But, to define requirements, we must be more precise. Te first step in test development is to extract a set of requirements (REQs) from


with a length less than n, strncpy() shall append null characters (‘\0’) aſter the copied characters in array s1 until n characters in total have been written. REQ-nomore: strncpy() shall not write


into the target array s1 beyond the first n characters. REQ-nochange: strncpy() shall not modify


array s2. REQ-return: strncpy() shall return the


value of s1. Te requirement REQ-nochange follows


from the declaration of s2 as a constant array, but this does not guarantee that an implementation of strncpy() does not write to s2. A test specification is then developed


for each requirement, defining how a test verifies the requirement is true. A single test specification usually leads to several different test cases covering the function’s input and output domains. Te test cases are implemented by the test. Te test specification links the requirement to the tests. For example, the test specifications


for the REQ-copystring and REQ-nomore requirements are as follows: Test specification for REQ-copystring: Call


the strncpy() function with different values for the n parameter (including n==0) equal to and larger than the length of the origin string. Verify that the origin string is copied into the target array up to the terminating null character. Test specification for REQ-nomore: For


all test cases, verify that the character with index n in the target array s1 is not modified. If that fits with the test, verify that also no characters beyond n are modified. Here, the test specification REQ-nomore


is implemented in the same test file as the other tests cases for strncpy(). Since the requirement must unconditionally hold for every call to strncpy() anyway, instead of creating new tests for this test specification, it is implemented by simply piggybacking an additional check on every case test for the other requirements instead of creating new tests.


Header files and macros Not all functions in the C Standard Library are only implemented as pre-compiled binaries, many also depend heavily on information contained in source header files. Tese define types, global variables and macros and are as much part of the library as the (pre-compiled) library functions. Many functions are implemented both as real functions and as macros. For speed and efficiency, it is common to use the macro implementation; SuperGuard tests both.


Figure 1: Role of the SuperGuard in the V model www.electronicsworld.co.uk October 2022 27


Page 1  |  Page 2  |  Page 3  |  Page 4  |  Page 5  |  Page 6  |  Page 7  |  Page 8  |  Page 9  |  Page 10  |  Page 11  |  Page 12  |  Page 13  |  Page 14  |  Page 15  |  Page 16  |  Page 17  |  Page 18  |  Page 19  |  Page 20  |  Page 21  |  Page 22  |  Page 23  |  Page 24  |  Page 25  |  Page 26  |  Page 27  |  Page 28  |  Page 29  |  Page 30  |  Page 31  |  Page 32  |  Page 33  |  Page 34  |  Page 35  |  Page 36  |  Page 37  |  Page 38  |  Page 39  |  Page 40