Skip to content

Commit 22438de

Browse files
committed
fix: lab8 no angr
1 parent 1a4e6b9 commit 22438de

File tree

3 files changed

+4
-84
lines changed

3 files changed

+4
-84
lines changed

.github/workflows/lab-autograding.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ jobs:
5656
if [ ${{ steps.lab.outputs.result }} -eq 6 ]; then
5757
sudo apt install -y llvm-14
5858
fi
59+
if [ ${{ steps.lab.outputs.result }} -eq 8 ]; then
60+
python3 -m pip install angr
61+
fi
5962
./validate.sh

lab3/main_test.js

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,4 @@ const {describe, it} = require('node:test');
22
const assert = require('assert');
33
const { Calculator } = require('./main');
44

5-
describe('Calculator', () => {
6-
describe('exp', () => {
7-
const calculator = new Calculator();
8-
9-
it('should throw "unsupported operand type" for non-finite numbers', () => {
10-
const invalidInputs = [NaN, Infinity, -Infinity, 'string', null, undefined];
11-
invalidInputs.forEach(input => {
12-
assert.throws(() => calculator.exp(input), Error('unsupported operand type'));
13-
});
14-
});
15-
16-
it('should throw "overflow" for large numbers', () => {
17-
const largeInputs = [1000, 10000, 100000];
18-
largeInputs.forEach(input => {
19-
assert.throws(() => calculator.exp(input), Error('overflow'));
20-
});
21-
});
22-
23-
it('should return correct exp value for valid inputs', () => {
24-
const testCases = [
25-
{ input: 0, expected: 1 },
26-
{ input: 1, expected: Math.exp(1) },
27-
{ input: -1, expected: Math.exp(-1) },
28-
];
29-
testCases.forEach(({ input, expected }) => {
30-
assert.strictEqual(calculator.exp(input), expected);
31-
});
32-
});
33-
});
34-
35-
describe('log', () => {
36-
const calculator = new Calculator();
37-
38-
it('should throw "unsupported operand type" for non-finite numbers', () => {
39-
const invalidInputs = [NaN, Infinity, -Infinity, 'string', null, undefined];
40-
invalidInputs.forEach(input => {
41-
assert.throws(() => calculator.log(input), Error('unsupported operand type'));
42-
});
43-
});
44-
45-
it('should throw "math domain error (1)" for zero', () => {
46-
const invalidInputs = [0];
47-
invalidInputs.forEach(input => {
48-
assert.throws(() => calculator.log(input), Error('math domain error (1)'));
49-
});
50-
});
51-
52-
it('should throw "math domain error (2)" for finite negative numbers', () => {
53-
const invalidInputs = [-1, -5, -100];
54-
invalidInputs.forEach(input => {
55-
assert.throws(() => calculator.log(input), Error('math domain error (2)'));
56-
});
57-
});
58-
59-
it('should return correct log value for valid inputs', () => {
60-
const testCases = [
61-
{ input: 1, expected: 0 },
62-
{ input: Math.E, expected: 1 },
63-
{ input: 10, expected: Math.log(10) },
64-
];
65-
testCases.forEach(({ input, expected }) => {
66-
assert.strictEqual(calculator.log(input), expected);
67-
});
68-
});
69-
});
70-
});
5+
// TODO: write your tests here

lab6/llvm-pass.so.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,12 @@ struct LLVMPass : public PassInfoMixin<LLVMPass> {
1111
PreservedAnalyses LLVMPass::run(Module &M, ModuleAnalysisManager &MAM) {
1212
LLVMContext &Ctx = M.getContext();
1313
IntegerType *Int32Ty = IntegerType::getInt32Ty(Ctx);
14-
Type *Int8PtrTy = Type::getInt8PtrTy(Ctx);
15-
1614
FunctionCallee debug_func = M.getOrInsertFunction("debug", Int32Ty);
1715
ConstantInt *debug_arg = ConstantInt::get(Int32Ty, 48763);
1816

1917
for (auto &F : M) {
2018
errs() << "func: " << F.getName() << "\n";
21-
if (F.getName() == "main") {
22-
IRBuilder<> Builder(&*F.getEntryBlock().getFirstInsertionPt());
2319

24-
Builder.CreateCall(debug_func, debug_arg);
25-
26-
Argument *ArgcArg = F.getArg(0);
27-
ArgcArg->replaceAllUsesWith(debug_arg);
28-
29-
Argument *ArgvArg = F.getArg(1);
30-
Value *GEP = Builder.CreateInBoundsGEP(
31-
Int8PtrTy,
32-
ArgvArg,
33-
ConstantInt::get(Int32Ty, 1)
34-
);
35-
Value *StrVal = Builder.CreateGlobalStringPtr("hayaku... motohayaku!");
36-
Builder.CreateStore(StrVal, GEP);
37-
}
3820
}
3921
return PreservedAnalyses::none();
4022
}

0 commit comments

Comments
 (0)