CS 3113 Spring 19

Logo

This is the web page for Operation Systems at the University of Oklahoma.

View the Project on GitHub oudalab/cs3113sp19

Assignment 0 — CS 3113 Spring 2019

Due 02/07/2019

For this assignment, we will make a small C program using the cloud resources that we will have for this class. You need to sign up for the Google Cloud using the directions previously given. Sign up for GitHub. Also, register as a student so you get unlimited private repositories.

After completing this assignment, you will have experience creating a and compiling a c file. You will also get used to working with the a version control system. Read this document in full before starting. Each section specifies steps you need to take to complete the homework.

Sign up for GCP an instance

Be sure to submit the form with your static ip address of your instance. https://goo.gl/forms/DEDUjnTMDLxXa3N33

If you have not created your instance, the instructions available here: https://oudalab.github.io/cs3113sp19/documents/cloud-config.pdf

GitHub

Fill out this form to sign up for GitHub: https://goo.gl/forms/SZ45hlj5EIwKUnGk1

Create a repository for your project on your instance (10 pts)

Create a private repository GitHub called cs3113sp19-assignment0

Add collaborators cegme and Vinothini-Rajasekaran by going to Settings > Collaborators.

Then go to your instance, create a new folder /hw and clone the repository in that folder. For example:

cd /
sudo mkdir /hw
sudo chown `whoami`:`whoami` /hw
chmod 777 /hw
cd hw
git clone https://github.com/cegme/cs3113sp19-assignment0

Renaming repo

Note that in class that we used a repository by a different name. To change it, use the directions shown here: https://help.github.com/articles/renaming-a-repository/.

# Update the url
git remote set-url origin https://github.com/USERNAME/cs3113sp19-assignment0

# Update the name of the folder
mv /hw/cs3113sp19-assignment1 /hw/cs3113sp19-assignment0

Perform the task below

Create a makefile

Your makefile should use the command make all to compile the code and the command clean to remove compiled and intermediate files. Your executable should be diamond.

Create a README file

The readme file should be all uppercase with either no extension or a .md extension. You should write your name in it, and example of how to run it, and a list of any web or external resources that you used for help. Note that you should not be copying code from any website not provided by the instructor.

Create a COLLABORATORS file

This file should contain a comma separated list describing who you worked with and a small text description describing the nature of the collaboration. This information should be listed in three fields as in the example is below:

Katherine Johnson, kj@nasa.gov, Helped me understand calculations
Dorothy Vaughan, doro@dod.gov, Helped me with multiplexed time management

Create a bats test file

Add tests for your code using the bats file. Here is an example bats test file.

#!/usr/bin/env bats


TEST5=`cat <<EOF
    x
   xxx
  xxxxx
 xxxxxxx
xxxxxxxxx
 xxxxxxx
  xxxxx
   xxx
    x
EOF
`

@test "five exes" {
  result="$(./diamond 5 x)"
  [ "$result" = "$TEST5" ]
}

Write code

Create a c file called diamond.c in the /hw/cs3113sp19-assignment0 directory. This C-program code when compiled should takes two parameters as command line input (1) an odd integer from 1-15 and (2) a single ASCII character. If the input is some number k, the height and width of the diamond should be (2*k-1). All output should be send to standard out (stdout).

Below is a skeleton for this program:

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{ 
    // Naive Error check
    if (argc != 3) {
        fprintf(stderr, "Two parameters an int and a char.\n");
        exit(-1);
    }
    
    // Get the size of the diamond
    int num = atoi(argv[1]);
    
    if (num < 1 || num > 15) {
        fprintf(stderr, "Then number must be between 1 and 15");
    }
    
    char *k;
    // Set the character k
    k = argv[2];
    
    /** TODO: Fill in here **/
    
    
    return 0;
}

Here is a sample run:

barrybonds@instance-1$ gcc -g diamond.c
barrybonds@instance-1$ ./a.out 2 .
 .
...
 .
barrybonds@instance-1$ ./a.out 7 .
      .
     ...
    .....
   .......
  .........
 ...........
.............
 ...........
  .........
   .......
    .....
     ...
      .

To test your program we will connect to your created VM. Compile the file using gcc -g -O3 diamond.c Then we will execute several test cases and check the output against the expected output.

Add git tag

When ready to submit, create a tag on your repository using git tag:

git tag v1.0
git push origin v1.0

Grading Criteria:

Task Percent
Cloud is configured 20%
Code compiles 30%
Code Passes all test cases 50%
Total 100%

(extra) travis continuous integration

In you are interested in adding continuous integration to your code. Add a file name .travis.yml with the contents below.

language: c
compiler:
  - gcc
dist: xenial
install:
  - make clean
  - make all
script: bats *bats 

We are using the bats system to test the code https://github.com/bats-core/bats-core. This website also has more information on bats https://www.engineyard.com/blog/bats-test-command-line-tools . The Travis CI website has more information on continuous integration with C https://docs.travis-ci.com/user/languages/c/.

Addenda

2019-01-28


Back to CS3113