$24
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 Lab Machine Remote Access
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One extremely easy way to access lab machines remotely that is
described in some detail in the "Accessing Unix/Linux Programming
Environments" guide is...
- ( ) Buying a second laptop and setting it up as a "dumb terminal" :
whenever it is booted it automatically connects to a remote machine
to mock its interface.
- ( ) Connecting to machines in a web browser via FASTX 3: it's as
easy as visiting a lab machine web address like
<https://csel-kh4240-01.cselabs.umn.edu>
- ( ) Adding Linux system call emulation to the Windows or Mac Kernel
through some crafty manipulations of binary files.
- ( ) Actually there are no easy ways to connect to remote lab
machines.
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 - Change ABC to 123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What does the following command sequence do?
,----
| > cd ~ # A
| > mkdir csci2021 # B
| > cd csci2021 # C
| > ls # D
| > cd .. # E
`----
,----
| - ( ) A. Changes to your home directory/folder
| B. Creates a folder named csci2021
| C. Changes the directory csci2021 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 csci2021,
| C. creates a second folder csci2021,
| 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 csci2021
| C. changes into the folder csci2021,
| 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 hello_c.c
=================
Open up and examine the program in the file `hello_c.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 `hello_c': notices the lack of the `.c'
extension. A session of compiling, running, and testing the program is
below with commentary on the right.
,----
| > make # compile the program 'hello_c'
| gcc -Wall -Wno-comment -Werror -g -o hello_c hello_c.c
|
| > file hello_c # check file type of program
| hello_c: ELF 64-bit LSB pie executable, x86-64, version
|
| > ./hello_c # run compiled program
| Goodbye Python. Goodbye Java.
| ...
|
| > make test-code
| ./testy test_lab01.org 2
| ============================================================
| == test_lab01.org : Lab01 Tests
| == Running 1 / 2 tests
| 2) CODE: hello_c output : FAIL -> results in file 'test-results/lab01-02-result.tmp'
| ============================================================
| RESULTS: 0.00 / 1.00 tests passed
|
|
| ============================================================
| == FAILURE RESULTS
| ============================================================
| (TEST 2) CODE: hello_c output
| COMMENTS:
| Runs the program 'hello_c' which must already be compiled and checks
| ...
`----
As indicated in the comments in `hello_c.c', there are a number of
typos, missing, and extraneous lines printed by the program. To make
the code pass the tests, you will simply need to correct `hello_c.c'
to match the output expected for the test. As the Comments for the
CODE test indicate, 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 in `hello_c.c' so that the output matches and testing the
code produces a success:
,----
| > make test-code
| gcc -Wall -Wno-comment -Werror -g -o hello_c hello_c.c
| ./testy test_lab01.org 2
| ============================================================
| == test_lab01.org : Lab01 Tests
| == Running 1 / 2 tests
| 2) CODE: hello_c output : 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: hello_c 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 hello_c *.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/hello_c.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.