{"id":28000627,"url":"https://github.com/sysprog21/lab0-c","last_synced_at":"2025-05-16T00:00:23.232Z","repository":{"id":33036707,"uuid":"149674932","full_name":"sysprog21/lab0-c","owner":"sysprog21","description":"C Programming Lab: Assessing Your C Programming Skills","archived":false,"fork":false,"pushed_at":"2025-05-08T07:07:34.000Z","size":808,"stargazers_count":457,"open_issues_count":5,"forks_count":1666,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-08T23:53:57.438Z","etag":null,"topics":["c","c-programming","csapp","linked-list","linux","programming-skills","valgrind"],"latest_commit_sha":null,"homepage":"https://wiki.csie.ncku.edu.tw/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysprog21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-20T21:53:05.000Z","updated_at":"2025-05-08T07:07:40.000Z","dependencies_parsed_at":"2023-02-19T15:31:18.840Z","dependency_job_id":"e94ad43c-4b21-47b3-b20d-3cb892d6c723","html_url":"https://github.com/sysprog21/lab0-c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Flab0-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Flab0-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Flab0-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Flab0-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysprog21","download_url":"https://codeload.github.com/sysprog21/lab0-c/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c-programming","csapp","linked-list","linux","programming-skills","valgrind"],"created_at":"2025-05-08T23:53:54.717Z","updated_at":"2025-05-16T00:00:22.346Z","avatar_url":"https://github.com/sysprog21.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lab0-c\nAssessing Your C Programming Skills\n\nThis lab will give you practice in the style of programming you will need to be able to do proficiently,\nespecially for the later assignments in the class. The material covered should all be review for you. Some\nof the skills tested are:\n* Explicit memory management, as required in C.\n* Creating and manipulating pointer-based data structures.\n* Working with strings.\n* Enhancing the performance of key operations by storing redundant information in data structures.\n* Implementing robust code that operates correctly with invalid arguments, including NULL pointers.\n\nThe lab involves implementing a queue, supporting both last-in, first-out (LIFO) and first-in-first-out (FIFO)\nqueueing disciplines. The underlying data structure is a circular doubly-linked list, enhanced to make some of\nthe operations more efficient.\n\n## Prerequisites\n\nThere are a few prerequisites which must be installed on your machine before you will\nbe able to build and run the autograders.\n\nThe following command will install all required and optional dependencies on Ubuntu\nLinux 20.04 or later:\n```shell\n$ sudo apt install build-essential git clang-format cppcheck aspell colordiff valgrind\n```\nSome distros like Arch Linux won't install `aspell-en` with `aspell`, and you must install it explicitly:\n```shell\n$ sudo pacman -S aspell-en\n```\n\nNote: [Cppcheck](https://cppcheck.sourceforge.io/) version must be at least 1.90, otherwise\nit might report errors with false positives. You can get its version by executing `$ cppcheck --version`.\nCheck [Developer Info](https://cppcheck.sourceforge.io/devinfo/) for building Cppcheck from source.\n\n### Integrate `clang-format` to `vim`\nIf you want to run `clang-format` automatically after saving with vim, \nclang-format supports integration for vim according to [Clang documentation](https://clang.llvm.org/docs/ClangFormat.html).\n\nBy adding the following into `$HOME/.vimrc`\n```shell\nfunction! Formatonsave()\n  let l:formatdiff = 1\n  py3f \u003cpath-to-clang-format.py\u003e/clang-format.py\nendfunction\nautocmd BufWritePre *.h,*.hpp,*.c,*.cc,*.cpp call Formatonsave()\n```\n\nThen, it has zero-effort integration into the coding workflow since it can handle formatting changes while saving a file.\nNote: on Ubuntu Linux 18.04, the path to `clang-format.py` is `/usr/share/vim/addons/syntax/`.  \n\n## Running the autograders\n\nBefore running the autograders, compile your code to create the testing program `qtest`\n```shell\n$ make\n```\n\nCheck the correctness of your code, i.e. autograders:\n```shell\n$ make test\n```\n\nCheck the example usage of `qtest`:\n```shell\n$ make check\n```\nEach step about command invocation will be shown accordingly.\n\nCheck the memory issue of your code:\n```shell\n$ make valgrind\n```\n\n* Modify `./.valgrindrc` to customize arguments of Valgrind\n* Use `$ make clean` or `$ rm /tmp/qtest.*` to clean the temporary files created by target valgrind\n\nExtra options can be recognized by make:\n* `VERBOSE`: control the build verbosity. If `VERBOSE=1`, echo each command in build process.\n* `SANITIZER`: enable sanitizer(s) directed build. At the moment, AddressSanitizer is supported.\n\n## Using `qtest`\n\n`qtest` provides a command interpreter that can create and manipulate queues.\n\nRun `$ ./qtest -h` to see the list of command-line options\n\nWhen you execute `$ ./qtest`, it will give a command prompt `cmd\u003e `.  Type\n`help` to see a list of available commands.\n\n## Files\n\nYou will handing in these two files\n* `queue.h` : Modified version of declarations including new fields you want to introduce\n* `queue.c` : Modified version of queue code to fix deficiencies of original code\n\nTools for evaluating your queue code\n* `Makefile` : Builds the evaluation program `qtest`\n* `README.md` : This file\n* `scripts/driver.py` : The driver program, runs `qtest` on a standard set of traces\n* `scripts/debug.py` : The helper program for GDB, executes `qtest` without SIGALRM and/or analyzes generated core dump file.\n\nHelper files\n* `console.{c,h}` : Implements command-line interpreter for qtest\n* `report.{c,h}` : Implements printing of information at different levels of verbosity\n* `harness.{c,h}` : Customized version of malloc/free/strdup to provide rigorous testing framework\n* `qtest.c` : Code for `qtest`\n\nTrace files\n* `traces/trace-XX-CAT.cmd` : Trace files used by the driver.  These are input files for `qtest`.\n  * They are short and simple.\n  * We encourage to study them to see what tests are being performed.\n  * XX is the trace number (1-17).  CAT describes the general nature of the test.\n  * All functions that need to be implemented are explicitly listed.\n  * If a colon is present in the title, all functions mentioned afterwards must be correctly implemented for the test to pass.\n* `traces/trace-eg.cmd` : A simple, documented trace file to demonstrate the operation of `qtest`\n\n## Debugging Facilities\n\nBefore using GDB debug `qtest`, there are some routine instructions need to do. The script `scripts/debug.py` covers these instructions and provides basic debug function. \n```shell\n$ scripts/debug.py -h\nusage: debug.py [-h] [-d | -a]\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -d, --debug    Enter gdb shell\n  -a, --analyze  Analyze the core dump file\n```\n* Enter GDB without interruption by **SIGALRM**.\n```shell\n$ scripts/debug.py -d\nReading symbols from lab0-c/qtest...done.\nSignal        Stop\tPrint\tPass to program\tDescription\nSIGALRM       No\tNo\tNo\t\tAlarm clock\nStarting program: lab0-c/qtest \ncmd\u003e \n```\n* When `qtest` encountered **Segmentation fault** while it ran outside GDB, we could invoke GDB in the post-mortem debugging mode to figure out the bug.\n\n  The core dump file was created in the working directory of the `qtest`.\n  * Allow the core dumps by using shell built-in command **ulimit** to set core file size.\n  ```shell\n  $ ulimit -c unlimited\n  $ ulimit -c\n  unlimited\n  ```\n  * Enter GDB and analyze\n  ```shell\n  $ scripts/debug.py -a\n  Reading symbols from lab0-c/qtest...done.\n  [New LWP 9424]\n  Core was generated by `lab0-c/qtest'.\n  Program terminated with signal SIGSEGV, Segmentation fault.\n  #0 ...\n  #1 ... (backtrace information)\n  #2 ...\n  (gdb) \n  ```\n\n## User-friendly command line\n[linenoise](https://github.com/antirez/linenoise) was integrated into `qtest`, providing the following user-friendly features:\n* Move cursor by Left and Right key\n* Jump the cursor over words by Ctrl-Left and Ctrl-Right key\n* Get previous or next command typed before by up and down key\n* Auto completion by TAB\n\n## Built-in web server\n\nA small web server is already integrated within the `qtest` command line interpreter,\nand you may use it by running the `web` command in its prompt.\n```shell\n$ ./qtest\ncmd\u003e web\nlisten on port 9999, fd is 3\n```\n\nRun the following commands in another terminal after the built-in web server is ready.\n```shell\n$ curl http://localhost:9999/new\n$ curl http://localhost:9999/ih/1\n$ curl http://localhost:9999/ih/2\n$ curl http://localhost:9999/ih/3\n$ curl http://localhost:9999/sort\n$ curl http://localhost:9999/quit\n```\n\n## License\n\n`lab0-c` is released under the BSD 2 clause license. Use of this source code is governed by\na BSD-style license that can be found in the LICENSE file.\n\nExternal source code:\n* [dudect](https://github.com/oreparaz/dudect): public domain\n* [git-good-commit](https://github.com/tommarshall/git-good-commit): MIT License\n* [linenoise](https://github.com/antirez/linenoise): BSD 2-Clause \"Simplified\" License\n* [tiny-web-server](https://github.com/7890/tiny-web-server): MIT License\n* [randombytes](https://github.com/dsprenkels/randombytes): MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysprog21%2Flab0-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysprog21%2Flab0-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysprog21%2Flab0-c/lists"}