lecture20 - Last time Chapter 14, The preprocessor...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Low-Level Programming Concepts CMSC 212 ecture 20 1 CMSC 212 Lecture 20 November 5, 2009 Last time Chapter 14, The preprocessor – file inclusion and header files – conditional compilation – defining parameterized macros Introduction to program testing – general concepts 2 CMSC 212 – white box testing – ways of measuring test coverage in white-box testing: line or statement coverage, branch coverage, and path coverage – black box testing and example Reading 3 CMSC 212 Testing programs, con't. 4 CMSC 212
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Tools to aid testing Language features (like assert() , to be covered soon) Test harness tools Code coverage tools – Using the lcov statement coverage tool for Linux (derived from the Free Software Foundation's gcov tool): 5 CMSC 212 1. Compile the program with flags -fprofile-arcs -ftest-coverage 2. Run the program on one or more test cases 3. Run lcov -c -d . -o coverage.out 4. Run genhtml coverage.out 5. This creates a file index.html in the current directory, which can be viewed with a web browser Chapter 15, Input/Output Functions 6 CMSC 212 Error reporting void perror(char * message ); – prints a description of the most recent error encountered by a system or library function, in the format " message : error description " – when many system calls and library functions encounter an error they also communicate an error code to the program by toring a value in the global variable rrno efined in 7 CMSC 212 storing a value in the global variable errno (defined in errno.h ) – given an error number (the value of errno ), the function char *strerror(int errnum) returns a pointer to a string that has a description of the error Terminating execution void exit(int status); /* in <stdlib.h> */ – ends the program at that point (without returning to the caller) – the exit status is available to other programs (can be accessed in the shell) to indicate why the program ended exit(0) is typical for no error (or return 0 from main() ) exit(-1) or some other nonzero value is typical for an error (a negative value is common) sh sh hell script syntax: 8 CMSC 212 – csh/tcsh shell script syntax: echo $status in the shell just prints the exit status of the last command # run some program or execute some command public01.x # $status is the exit status of the prior command if ($status == 0) then echo "public01.x quit with successful status" else echo "public01.x exited with status " $status endif
Background image of page 2
The standard I/O library Most I/O is stream-based and buffered to allow efficient operations – interactive output is normally flushed at useful points printf("This output probably won't be seen "); printf("until a newline is printed."); printf("Hello!!!\n"); /* \n causes a flush */ 9 CMSC 212 – or you can explicitly flush a stream by calling the library function fflush() Types of streams Text streams are composed of lines of text, each
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

lecture20 - Last time Chapter 14, The preprocessor...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online