Skip to content
Snippets Groups Projects
Commit e06673a1 authored by tuhe's avatar tuhe
Browse files

updates

parent d3b39e1e
Branches
No related tags found
No related merge requests found
Showing
with 289 additions and 0 deletions
# Student makefile for the Hello Lab
all:
gcc hello.c -o hello
clean:
rm -rf *~ hello
This directory contains all of the code files for the Hello Lab,
including the files that are handed out to students.
Files:
# Autograder and solution files
Makefile Makefile and ...
README ... README for this directory
driver.sh* Autograder
hello.c Solution hello.c file
# Files that are handed out to students
Makefile-handout Makefile and ...
README-handout ... README handed out to students
hello.c-handout Blank hello.c file handed out to students
For this lab, you should write a tiny C program, called "hello.c",
that prints "hello, world" to stdout and then indicates success by
exiting with a status of zero.
To test your work:
linux> make clean; make; ./hello
To run the same autograder that Autolab will use when you submit:
linux> ./driver.sh
Files:
README This file
Makefile Compiles hello.c
driver.sh Autolab autograder
hello.c Empty C file that you will edit
#!/bin/bash
# driver.sh - The simplest autograder we could think of. It checks
# that students can write a C program that compiles, and then
# executes with an exit status of zero.
# Usage: ./driver.sh
# Compile the code
echo "Compiling hello.c"
(make clean; make)
status=$?
if [ ${status} -ne 0 ]; then
echo "Failure: Unable to compile hello.c (return status = ${status})"
echo "{\"scores\": {\"Correctness\": 0}}"
exit
fi
# Run the code
echo "Running ./hello"
./hello
status=$?
if [ ${status} -eq 0 ]; then
echo "Success: ./hello runs with an exit status of 0"
echo "{\"scores\": {\"Correctness\": 100}}"
else
echo "Failure: ./hello fails or returns nonzero exit status of ${status}"
echo "{\"scores\": {\"Correctness\": 0}}"
fi
exit
/* Solution for the Hello Lab */
#include <stdio.h>
int main()
{
printf("Hello, world\n");
return 0; /* important to return zero here */
}
/*
* Hello Lab
*/
all:
tar xvf autograde.tar
cp hello.c hello-handout
(cd hello-handout; ./driver.sh)
clean:
rm -rf *~ hello-handout
File added
/* Solution for the Hello Lab */
#include <stdio.h>
int main()
{
printf("Hello, world\n");
return 0;
}
Contains the HTML writeup for the Hello Lab that students using the
"View writeup" link.
<h2>Hello Lab</h2>
In this lab, you will write a C program, called <kbd>hello.c</kbd>, that prints "Hello, world" and
then exits with a status of zero (the conventional way to indicate a
successful termination).
<p>
Download the lab materials from Autolab using the "Download handout" link.
<p>
Submit your hello.c file to Autolab using the "Submit file" link.
# Makefile for the Hello Lab
all:
gcc hello3.c -o hello3
clean:
rm -rf *~ hello3
# Student makefile for the Hello Lab
all:
gcc hello.c -o hello
clean:
rm -rf *~ hello
This directory contains all of the code files for the Hello Lab,
including the files that are handed out to students.
Files:
# Autograder and solution files
Makefile Makefile and ...
README ... README for this directory
driver.sh* Autograder
hello.c Solution hello.c file
# Files that are handed out to students
Makefile-handout Makefile and ...
README-handout ... README handed out to students
hello.c-handout Blank hello.c file handed out to students
For this lab, you should write a tiny C program, called "hello.c",
that prints "hello, world" to stdout and then indicates success by
exiting with a status of zero.
To test your work:
linux> make clean; make; ./hello
To run the same autograder that Autolab will use when you submit:
linux> ./driver.sh
Files:
README This file
Makefile Compiles hello.c
driver.sh Autolab autograder
hello.c Empty C file that you will edit
#!/bin/bash
# driver.sh - The simplest autograder we could think of. It checks
# that students can write a C program that compiles, and then
# executes with an exit status of zero.
# Usage: ./driver.sh
# Compile the code
# echo "Compiling hello3.c"
# python3 -c "print('Hello world from python 2')"
# python3 --version
python3 driver_python.py
(make clean; make)
status=$?
if [ ${status} -ne 0 ]; then
echo "Failure: Unable to compile hello3.c (return status = ${status})"
echo "{\"scores\": {\"Correctness\": 0}}"
exit
fi
# Run the code
echo "Running ./hello3"
./hello3
status=$?
if [ ${status} -eq 0 ]; then
echo "Success: ./hello3 runs with an exit status of 0"
echo "{\"scores\": {\"Correctness\": 100}}"
else
echo "Failure: ./hello fails or returns nonzero exit status of ${status}"
echo "{\"scores\": {\"Correctness\": 0}}"
fi
exit
print("="*10)
tag = "[driver_python.py]"
print(tag, "I am going to have a chamor of a time grading your file!")
import os
import glob
import shutil
import sys
import pickle
# import io
import time
sys.stderr = sys.stdout
wdir = os.getcwd()
# print(os.system("cd"))
def pfiles():
print("> Files in dir:")
for f in glob.glob(wdir + "/*"):
print(f)
print("---")
# shutil.unpack_archive("student_sources.zip")
student_token_file = '{{student_token_file}}'
instructor_grade_script = '{{instructor_grade_file}}'
grade_file_relative_destination = "{{grade_file_relative_destination}}"
with open(student_token_file, 'rb') as f:
results = pickle.load(f)
sources = results['sources'][0]
pfiles()
host_tmp_dir = wdir + "/tmp"
import subprocess
import docker_helpers
print(f"{host_tmp_dir=}")
print(f"{student_token_file=}")
print(f"{instructor_grade_script=}")
command, token = docker_helpers.student_token_file_runner(host_tmp_dir, student_token_file, instructor_grade_script, grade_file_relative_destination)
command = f"cd tmp && {command}"
def rcom(cm):
print(f"running... ", cm)
start = time.time()
rs = subprocess.run(cm, capture_output=True, text=True, shell=True)
print(rs)
print("result of running command was", rs.stdout, "err", rs.stderr, "time", time.time() - start)
rcom("ls")
rcom('python3 --version')
rcom('python --version')
start = time.time()
rcom(command)
# print("Calling sub process...")
# result = subprocess.run(command.split(), capture_output=True, text=True, shell=True).stdout
# print("result of running command was", result, "time", time.time() - start)
import time
time.sleep(1)
# print("> Files in dir:")
pfiles()
for f in glob.glob(host_tmp_dir + "/cs101/*"):
print("cs101/", f)
print("---")
print(f"{token=}")
ls = glob.glob(token)
print(ls)
f = ls[0]
with open(f, 'rb') as f:
results = pickle.load(f)
print("results")
print(results['total'])
# if os.path.exists(host_tmp_dir):
# shutil.rmtree(host_tmp_dir)
# with io.BytesIO(sources['zipfile']) as zb:
# with zipfile.ZipFile(zb) as zip:
# zip.extractall(host_tmp_dir
print("="*10)
\ No newline at end of file
/* Solution for the Hello Lab */
#include <stdio.h>
int main()
{
printf("Hello, world\n");
return 0; /* important to return zero here */
}
/*
* Hello Lab
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment