Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Starter code The starter code for this assignment can be found under / student / cmpt 2 1 4 / 2 0 2 4 /

Starter code
The starter code for this assignment can be found under /student/cmpt214/2024/summer/starter/a7:
- list.c
- test-list.c (this file is not to be modified)
Question 1[20 points]
Write a header file list.h for the provided C file list.c. As discussed in class, the header
file must contain the following:
Prototypes for all (non-internal) list function,
all relevant type definitions,
all relevant macros, and
include guard.
Write an internal header file list internal.h which provides:
Prototypes and for internal functions,
all relevant type definitions,
all relevant macros, and
include guard.
Question 2[20 points]
Using the provided file list.c, you are going to split the file into 4 C files containing the fol-
lowing functions. Each of the C files must #include the headers list.h and list internal.h
you created in Question 1.
(a) list-init.c
- list init
(b) list-adder.c
- list prepend
- list append
- list insert before
- list insert after
2
(c) list-remove.c
- list pop
- list remove
- list clear
(d) list-process.c
- list find
(e) list-util.c
- list print
(f) list-internal.c
- list internal prepend
- list internal pop
- list internal before
- list internal find tail
Question 4[50 points]
Write a Makefile that builds three executable objects test-list-static, test-list-dynamic,
and list-cli. The executable object test-list-static is created by linking the static li-
brary liblist.a and the object file test-list.o. The executable object test-list-dynamic
is created by linking the dynamic library liblistdynamic.so and the object file test-list.o.
The executable object list-cli is created by linking either liblist.a or liblistdynamic.so
(your choice) to list-cli.o.
To build the the static library liblist.a, you should use the ar utility to archive the 6 object
files list-init.o, list-adder.o, list-remove.o, list-process.o, list-internal.o,
and list-util.o into a static library. The executable object test-list-dynamic is created
by linking the dynamic library liblistdynamic.so and the object file test-list.o.
To build the the dynamic library liblistdynamic.so, you should use gcc to combine the 6
object files list-init.o, list-adder.o, list-remove.o, list-process.o, list-internal.o,
and list-util.o into one shared object.
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),
3
static libraries must be created using the ar utility,
dynamic libraries must be created using gcc and the -shared option,
object files, libraries, and executable objects should be created in the proper directories
depending on the type of system running the Makefile, and
symbolic links should be created for the three executable objects test-list-static,
test-list-dynamic and list-cli at the root of the project (same location where the
Makefile exists).
If everything works, you should be able to run the two executable files and see the message
ALL TESTS PASSED.
Testing [10 points]
In this part, you will test the list using an end-to-end approach. (test-list already provides
a unittest approach)
You will construct 5 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
(list-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 <(./ list - cli < test -x - in . txt )<( cat test -x - out . txt )| wc -l )==0
&& echo " PASS "|| echo " FAIL "

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions