CSCI 4061 Lab01: Basic Setup
- Due: 11:59pm Mon 2/01/2021 on Gradescope
- Approximately 1.00% of total grade
CODE DISTRIBUTION: lab01-code.zip
- Download the code distribution
- See further setup instructions below
CHANGELOG: Empty
1 Rationale
This lab will introduce students to the basic UNIX programming environment which will be used throughout the course. Staff will be on hand to help students set up their environment and complete the lab work.
A UNIX environment is needed to complete the exercises and students are encouraged to work through the Accessing Unix/Linux Programming Environments tutorial to get their environment set up.
The collatz
program in this lab is a copy of the program that is
featured as part of HW01. Complete it here to earn an Engagement Point
for the Lab.
Grading Policy
Credit for this Lab is earned by completing the exercises here and
submitting a Zip of the work to Gradescope. Students are responsible
to check that the results produced locally via make test
are
reflected on Gradescope after submitting their completed
Zip. Successful completion earns 1 Engagement Point.
Lab Exercises are open resource/open collaboration and students are encouraged to coopearte on labs. Students may submit work as groups of up to 5 to Gradescope: one person submits then adds the names of their group members to the submission.
See the full policies in the course syllabus.
2 Codepack
The codepack for this lab is linked at the top of this document. Always download it and unzip/unpack it. It should contain the following files which are briefly described.
File | Use | Description |
---|---|---|
QUESTIONS.txt |
EDIT | Questions to answer: fill in the multiple choice selections in this file. |
collatz_main.c |
EDIT | C file to; edit it to complete for testing |
collatz_funcs.c |
EDIT | C file to; edit it to complete for testing |
collatz.h |
Header | Header file, do not edit |
QUESTIONS.txt.bk |
Backup | Backup copy of the original file to help revert if needed |
Makefile |
Build | Enables make test and make zip |
testy |
Testing | Test running scripts |
test_lab01.org |
Testing | Tests for this lab |
test_collatz.org |
Testing | Tests specifically for Collatz program |
3 Setup
- Staff will briefly survey these instructions and then ask students to form groups to work on the lab exercises. Take this as an opportunity to meet some classmates: having a community of support makes any class easier to handle
- You are NOT required to work in a group but many students find it helpful to form some connections to help them throughout the semester and Labs are a place you might do that.
- Find out if group members complement you: if they have the same questions, are using a similar platform (Windows/Mac), listen to when you talk about something, or generally seem friendly, it's likely you can help each other. Consider swapping contact information to work again in the future.
- Spend some time Getting access to a Unix Environment using this tutorial Accessing Unix/Linux Programming Environments. *Request help from Staff if you are having trouble with your environment*. If you are in a hurry, you can use Vole through a web browser.
4 Overview of Lab Work
- If at any point you become confused by what to do next ask for help from your labmates or course staff.
Download the
lab01-code.zip
file linked at the top of this document into your Unix environment and unzip it. In most UNIX environments you can use the terminal command> unzip lab01-code.zip
to accomplish this. A number of files will be created in a the new folder
lab01-code/
.- Find and open the
QUESTIONS.txt
file in a text editor which contains further instructions on what to do. There are several asks to play with basic UNIX commands. Execute the commands indicated and observer their results. Some parts of the text file are marked with
QUESTION
and have multiple choices. Mark the correct response as follows:QUESTION: Which of these is correct? - ( ) This is a wrong answer - ( ) This is also wrong - (X) This is the correct answer - ( ) And another wrong answer
When you have filled in all your answers, check them via
> make test-quiz
Some activities will be based on writing CODE and marked as such. These will involve editing a file like the provided
hello.c
to complete it. Once you have completed the code necessary check it via> make test-code
You can run tests for both the QUIZ and CODE sections with
> make test
which you should always do prior to submitting
When you complete the QUIZ and CODE questions, create a zip of your lab work via
> make zip
and then upload the file to Gradscope as per the instructions in the last section.
5 QUESTIONS.txt File Contents
Below are the contents of the QUESTIONS.txt
file for the lab.
Follow the instructions in it to complete the QUIZ and CODE questions
for the lab.
__________________ LAB 01 QUESTIONS __________________ Lab Instructions ================ Follow the instructions below to experiment with topics related to this lab. - For sections marked QUIZ, fill in an (X) for the appropriate response in this file. Use the command `make test-quiz' to see if all of your answers are correct. - For sections marked CODE, complete the code indicated. Use the command `make test-code' to check if your code is complete. - DO NOT CHANGE any parts of this file except the QUIZ sections as it may interfere with the tests otherwise. - If your `QUESTIONS.txt' file seems corrupted, restore it by copying over the `QUESTIONS.txt.bk' backup file. - When you complete the exercises, check your answers with `make test' and if all is well, create a zip file with `make zip' and upload it to Gradescope. Ensure that the Autograder there reflects your local results. - IF YOU WORK IN A GROUP only one member needs to submit and then add the names of their group. Programming Environment ======================= The course will require you to do some programming in a Unix/Linux environment and the course staff have prepared a guide to getting access to such an environment here: <https://www-users.cs.umn.edu/~kauffman/tutorials/unix-environment.html> Discuss with your table-mates in lab (or contemplate on your own) what environment you will Primarily use and what will be your Backup. You can pick a method that makes your life easiest, but since you are going to be writing C and Assembly code and running it, occasionally on remote machines, make sure to spend some time configuring an environment that will help you focus on course problems rather than tech problems. All students should be aware of the following options for accessing Unix environments. QUIZ VOLE System ~~~~~~~~~~~~~~~~ One easy method to access a Unix Environment is the UMN's VOLE system. Which of these describes VOLE best? - ( ) It's a web site that describes Unix commands making it easier to understand those systems. - ( ) It's a web interface that gives you a Graphical Unix environment without needing to install anything. - ( ) It's a terminal command that allows easy access to the UMN's computing systems. - ( ) You know what a vole is, Morty, you know what a VOLE is? It's a, it's a rodent that mates for life, Morty. This is the chemical released in the mammal's brain, ...that makes it fall in love. What's a common complaint among students about VOLE? - ( ) It doesn't give access to the files that are stored on the CSE Lab systems - ( ) It only provides a terminal interface so you need to learn a terminal text editor. - ( ) It lags and ssssssssstalls frequently because doing graphics over the network requires a fast internet connection - ( ) It is not the opposite of a Mantis. QUIZ Secure Shell ~~~~~~~~~~~~~~~~~ All recent major platforms (Windows / Mac / Linux) come with the `ssh / scp' tools pre-installed. What does the following command do? ,---- | > ssh kauf0095@atlas.cselabs.umn.edu `---- - ( ) Silences the user `kauff095' on the machine `atlas' so that user can no longer type any commands and must reset their password. - ( ) Opens an unsecure connection to the machine `atlas' for the user `kauf0095' and allows anyone typing to the command to act as that user on `atlas' without password verification and without any encryption of the connection. - ( ) Opens a secure connection to the machine `atlas' for the user `kauf0095' and, after verifying a password, opens a terminal/shell on that machine for further commands. What does the following command do? ,---- | > scp -r hw01-code/ kauf0095@atlas.cselabs.umn.edu: `---- - ( ) It copies the directory `hw01-code' recursively to the remote machine `atlas' for user `kauf0095' allowing the contents of the entire folder to be moved from the local computer to a different computer. Password verification is required for user `kauf0095'. - ( ) It copies the directory `hw01-code' to a new folder name that starts with `kauf0095@atl...' but uses a more efficient algorithm than the standard `cp' copy command. - ( ) It reverses the names of all files in the directory `hw01-code' and stores the results in a new file named `kauf0095@atla...' Unix Terminal Basics ==================== Explore the UNIX terminal a bit. Ask for help from a classmate or Staff member if you don't know how to open a terminal on your system. Type the below commands in and then indicate what their purpose is. QUIZ Command Basics ~~~~~~~~~~~~~~~~~~~ What does the following command sequence do? ,---- | > cd ~ # A | > mkdir csci4061 # B | > cd csci4061 # C | > ls # D | > cd .. # E `---- ,---- | - ( ) A. Changes to your home directory/folder | B. Creates a folder named csci4061 | C. Changes the directory csci4061 to be your home folder | D. lists the files in the current folder, | E. changes the directory .. to be your home folder | | - ( ) A. Creates a directory/folder named ~ (tilde) | B. creates a file named csci4061, | C. creates a second folder csci4061, | D. lists the files in the current folder, | E. moves up one folder | | - ( ) A. Changes to your home directory/folder, | B. creates a folder named csci4061 | C. changes into the folder csci4061, | D. lists the files in the current folder, | E. moves up one folder `---- Checking Your Quiz Answers ========================== To check if your quiz answers are correct, open a terminal and change into the `lab01-code' directory. Type the command ,---- | > make test-quiz `---- which will report either success or a failure. The test does not report WHICH questions are incorrect and if you get stuck, get some help from a staff member to sort out which of the multiple choice questions above is incorrect. CODE in collatz =============== The lab code pack comes with a copy of the `collatz' program files studied in HW01. The purpose of the remaining CODE exercise is to ensure you have your environment set up and to compile/edit/debug/run C programs like it. It also introduces conventions for the remaining labs like the use of `make test and ~make zip'. Open up and examine the program in the files `collatz_main.c' and `collatz_funcs.c'. This is a C program and to see what it in action, you will need to compile and run it in a terminal. Navigate your terminal to the `lab01-code' directory. You can use the provided build tools to create the C program by typing ,---- | > make `---- This should provide output which runs the `gcc' compiler and creates the runnable program `collatz_main': notice the lack of the `.c' extension. A session of compiling, running, and testing the program is below with commentary on the right. ,---- | > make # BUILD PROGRAMS | gcc -Wall -g -c collatz_funcs.c | gcc -Wall -g -c collatz_main.c | gcc -Wall -g -o collatz_main collatz_funcs.o collatz_main.o | collatz_main is ready | | | > ./collatz_main # RUN INTERACTIVELY | Enter the starting integer: | >> 22 | The next value in the Collatz sequence is 11 | Show output of steps (0:NO, any other int: yes): | >> 1 | Step 0: 22 | Step 1: 11 | Step 2: 34 | Step 3: 17 | Step 4: 52 | Step 5: 26 | Step 6: 13 | Step 7: 40 | Step 8: 20 | Step 9: 10 | Step 10: 5 | Step 11: 16 | Step 12: 8 | Step 13: 4 | Step 14: 2 | Step 15: 1 | The starting value 22 converged to 1 in 15 steps | | > make test # RUN TESTS | gcc -Wall -g -o test_collatz test_collatz.c collatz_funcs.o collatz.h | ./testy test_collatz.org | ============================================================ | == test_collatz.org : collatz_func.c and collatz_main.c tests | == Running 16 / 16 tests | 1) All Tests : | 2) collatz_next(1) : FAIL -> results in file 'test-results/collatz-02-result.tmp' | 3) collatz_next(0) : ok | 4) collatz_next(-5) : ok | 5) collatz_next(5) : ok | 6) collatz_next(16) : ok | 7) collatz_next(20) : ok | 8) collatz_next(15) : ok | 9) collatz_steps() from -7 : ok | 10) collatz_steps() from 1 : ok | 11) collatz_steps() from 5 : ok | 12) collatz_steps() from 30 : ok | 13) collatz_steps() from 14 : FAIL -> results in file 'test-results/collatz-13-result.tmp' | 14) collatz_main session from 5 : ok | 15) collatz_main session from 11 : ok | 16) collatz_main session from 12 : FAIL -> results in file 'test-results/collatz-16-result.tmp' | ============================================================ | RESULTS: 0.81 / 1.00 tests passed | | > `---- There are some problems with the `collatz' program which require fixing. Examine the test result files indicated to get insight and make adjustments to the code to pass all tests. Failures report differences between the expected and actual output with symbols between the side-by-side comparison. These symbols are those used by the comparison program `diff' and are as follows: ,---- | > means there is an extra ACTUAL line that doesn't match anything in EXPECT | < means there is a line missing in ACTUAL that is present in EXPECT | | means the lines match closely but some characters differ `---- Edit code so that the output matches and testing the code produces a success: ,---- | > make test | gcc -Wall -g -o test_collatz test_collatz.c collatz_funcs.o collatz.h | ./testy test_collatz.org | ============================================================ | == test_collatz.org : collatz_func.c and collatz_main.c tests | == Running 16 / 16 tests | 1) All Tests : | 2) collatz_next(1) : ok | 3) collatz_next(0) : ok | 4) collatz_next(-5) : ok | 5) collatz_next(5) : ok | 6) collatz_next(16) : ok | 7) collatz_next(20) : ok | 8) collatz_next(15) : ok | 9) collatz_steps() from -7 : ok | 10) collatz_steps() from 1 : ok | 11) collatz_steps() from 5 : ok | 12) collatz_steps() from 30 : ok | 13) collatz_steps() from 14 : ok | 14) collatz_main session from 5 : ok | 15) collatz_main session from 11 : ok | 16) collatz_main session from 12 : ok | ============================================================ | RESULTS: 1.00 / 1.00 tests passed `---- Submitting a Zip for Gradescope =============================== Once you have your QUIZ answers for the `QUESTIONS.txt' file correct and your CODE completed, do one final check via `make test': ,---- | > make test | ./testy test_lab01.org | ============================================================ | == test_lab01.org : Lab01 Tests | == Running 2 / 2 tests | 1) QUIZ: QUESTIONS.txt : ok | 2) CODE: collatz output : ok | ============================================================ | RESULTS: 1.00 / 1.00 tests passed `---- If everything looks ok, you are ready to submit. Do so by creating a zip file via `make zip' ,---- | > make zip | rm -f collatz_main *.o | rm -rf test-results | rm -f lab01-code.zip | cd .. && zip "lab01-code/lab01-code.zip" -r "lab01-code" | zip warning: name not matched: lab01-code/test_lab01.org~ | adding: lab01-code/ (stored 0%) | adding: lab01-code/QUESTIONS.md5 (stored 0%) | adding: lab01-code/QUESTIONS.txt (deflated 61%) | adding: lab01-code/QUESTIONS.txt.bk (deflated 61%) | adding: lab01-code/testy (deflated 73%) | adding: lab01-code/collatz_funcs.c (deflated 51%) | adding: lab01-code/Makefile (deflated 60%) | adding: lab01-code/test_lab01.org (deflated 47%) | Zip created in lab01-code.zip `---- The zip file named `lab01-code.zip' should be uploaded to Gradescope under the `Lab01' assignment. Once uploaded, the same `make test' check will be run and you should verify its success as this will earn you your lab Engagement Point (1% of your overall grade). IF YOU ARE WORKING IN A GROUP: only one student needs to upload the Zip file and can add up to 4 other students (groups of 5) to the submission who will also receive credit for the lab work.
6 Submission
6.1 Check via make test
Once you have your QUIZ answers for the QUESTIONS.txt
file correct and your CODE completed, do one final check via make test
:
> make test ./testy test_lab01.org ============================================================ == test_lab01.org : Lab01 Tests == Running 2 / 2 tests 1) QUIZ: QUESTIONS.txt : ok 2) CODE: collatz output : ok ============================================================ RESULTS: 1.00 / 1.00 tests passed
6.2 Create a Zip
If everything looks ok, you are ready to submit. Do so by creating a zip file via make zip
> make zip rm -f collatz_main test_collatz *.o Removing temporary test files rm -rf *.o test_collatz test-results rm -f lab01-code.zip cd .. && zip "lab01-code/lab01-code.zip" -r "lab01-code" adding: lab01-code/ (stored 0%) adding: lab01-code/collatz.h (deflated 24%) adding: lab01-code/test_collatz.c (deflated 59%) adding: lab01-code/collatz_funcs.c (deflated 58%) adding: lab01-code/test_collatz.org (deflated 79%) adding: lab01-code/QUESTIONS.md5 (stored 0%) adding: lab01-code/QUESTIONS.txt (deflated 67%) adding: lab01-code/QUESTIONS.txt.bk (deflated 67%) adding: lab01-code/testy (deflated 73%) adding: lab01-code/collatz_main.c (deflated 54%) adding: lab01-code/Makefile (deflated 62%) adding: lab01-code/test_lab01.org (deflated 74%) Zip created in lab01-code.zip
6.3 Submitting to Gradescope
NOTE: The pictures below reference another class (CSCI 2021) but the instructions are the same for this course.
The zip file named lab01-code.zip
should be uploaded to Gradescope
under the Lab01
assignment. Once uploaded, the same make test
check will be run and you should verify its success as this will earn
you your lab Engagement Point (1% of your overall grade).
The following pictures illustrate how to submit the code.
Make sure to check that your submission passes tests online; otherwise you'll lose out on your Engagement Point. You can resubmit as many times as you wish up to the Lab deadline (usually Tuesday nights).
No late submission are accepted for lab work.
6.4 Adding Group Members
IF YOU ARE WORKING IN A GROUP: only one student needs to upload the Zip file and can add up to 4 other students (groups of 5) to the submission who will also receive credit for the lab work.
The following pictures show where you can add group members AFTER uploading a Zip file.