Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Makefile [ 4 0 points ] Write a Makefile that builds the executable object test - map, map - cli, and the library libmap.a .

Makefile [40 points]
Write a Makefile that builds the executable object test-map, map-cli, and the library
libmap.a. The executable objects test-map and map-cli are created by linking the library
libmap.a and the object file test-map.o / map-cli.o (respectively). To build the library
libmap.a, you should use the ar utility to archive the 2 object files map-modify.o, and
map-util.o.
As discussed in class, the following should apply to your Makefile to receive full credit:
The Makefile should contain the all and clean targets,
the proper compiler flags (CFLAGS) and preprocessor flags (CPPFLAGS) should be used,
each C source file should be compiled separately into the corresponding object file
(using the -c option with gcc),
static libraries must be created using the ar utility,
object files, libraries, and executable objects should be placed in their respective loca-
tions based on the directory structure discussed in class, and
symbolic links should be created for the executable objects test-map and map-cli at
the root of the project (same location where the Makefile exists).
Creating a header file [20 points]
Write a header file map.h for the provided C file map.c. As discussed in class, the header
file must contain the following:
Prototypes for all map functions,
all relevant type definitions,
all relevant macros, and
include guard.
Implementing the functionality [20 points]
Using the provided file map.c, you are going to split the file into 2 C files containing the
following functions. Each of the C files must #include the header file map.h you created.
2
(a) map-modify.c
- map add
- map remove
- map clear (can also be used to initialize a new map)
(b) map-util.c
- map find
- map size
- map print
(c) map-cli.c
- main
Testing [20 points]
In this part, you will test your libmap. But we will use both a unittest approach and an
end-to-end approach.
Unittests
First you will create multiple unittest functions of the following functions:
map add -4 tests
map remove -3 tests
map clear -1 test
map find -2 tests
map size -2 tests
Each of these functions (12 total) should initialize data it needs and preform a single test
action. i.e. inserting to an empty list, as well as programmatically validate the result,
returning 0 on success, and -1 on failure. Your unittests should not require outside verification
of your code.
In addition, you should create a main function which runs all of these tests printing their
name and result. The main function should return 0 only if all tests are successful.
3
end-to-end
You will construct 4 testcases which test a more complete set (combine different behaviours
together) of functionality. These tests are comprised of a short description (what the test
case is supposed to test and why), input data (stdin input), expected stdout output, the
actual output from the program.
To make your tests usable you will break this into 1 file that summarizes all the tests
(map-testing.txt), then each test will have a pair of files:
test-x-in.txt that contains the stdin
test-x-out.txt that contains the expected stdout output from the program
To run a test, you can use the following command (all of the following must be on a single
line when you type it into the terminal):
test $ ( diff - wB <(./ map - cli < test -x - in . txt )<( cat test -x - out . txt )| wc -l )==0
&& echo " PASS "|| echo " FAIL "
4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions