Skip to content

Commit 24cbf50

Browse files
committed
fix: lab8 no angr
1 parent ad582ca commit 24cbf50

3 files changed

Lines changed: 3 additions & 174 deletions

File tree

.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: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -3,156 +3,3 @@ const assert = require('assert');
33
const { Calculator } = require('./main');
44

55
// TODO: write your tests here
6-
7-
describe("test Calculator", () => {
8-
const calculator = new Calculator;
9-
// console.log(calculator.exp(1000000000));
10-
describe("exp(x) testing", () => {
11-
it("error testcases", () => {
12-
const testcases = [
13-
{ param: [Infinity], expected: {
14-
name: 'Error',
15-
message: 'unsupported operand type'
16-
} },
17-
{ param: [-Infinity], expected: {
18-
name: 'Error',
19-
message: 'unsupported operand type'
20-
} },
21-
{ param: ['abc'], expected: {
22-
name: 'Error',
23-
message: 'unsupported operand type'
24-
} },
25-
{ param: [1234567890], expected: {
26-
name: 'Error',
27-
message: 'overflow'
28-
} }
29-
];
30-
for (tc of testcases) {
31-
assert.throws(() => {
32-
calculator.exp.apply(this, tc.param)},
33-
tc.expected
34-
);
35-
}
36-
});
37-
38-
/* it("isFinite Error", () => {
39-
assert.throws(() => {
40-
calculator.exp(Infinity);
41-
}, {
42-
name: 'Error',
43-
message: 'unsupported operand type'
44-
});
45-
assert.throws(() => {
46-
calculator.exp('abc');
47-
}, {
48-
name: 'Error',
49-
message: 'unsupported operand type'
50-
});
51-
});
52-
it("overflow Error", () => {
53-
assert.throws(() => {
54-
calculator.exp(1000000000);
55-
}, {
56-
name: 'Error',
57-
message: 'overflow'
58-
});
59-
});
60-
*/
61-
it("normal behavior", () => {
62-
const testcases = [
63-
{ param: [1], expected: Math.exp(1) },
64-
{ param: [16], expected: Math.exp(16) },
65-
{ param: [-3], expected: Math.exp(-3) },
66-
{ param: [0.794], expected: Math.exp(0.794) }
67-
];
68-
for (const tc of testcases) {
69-
assert.strictEqual(calculator.exp.apply(this, tc.param), tc.expected);
70-
}
71-
});
72-
});
73-
describe("log(x) testing", () => {
74-
it("error testcases", () => {
75-
const testcases = [
76-
{ param: [Infinity], expected: {
77-
name: 'Error',
78-
message: 'unsupported operand type'
79-
} },
80-
{ param: [-Infinity], expected: {
81-
name: 'Error',
82-
message: 'unsupported operand type'
83-
} },
84-
{ param: ['abc'], expected: {
85-
name: 'Error',
86-
message: 'unsupported operand type'
87-
} },
88-
{ param: [0], expected: {
89-
name: 'Error',
90-
message: 'math domain error (1)'
91-
} },
92-
{ param: [-1], expected: {
93-
name: 'Error',
94-
message: 'math domain error (2)'
95-
} },
96-
{ param: [-1000000], expected: {
97-
name: 'Error',
98-
message: 'math domain error (2)'
99-
} }
100-
];
101-
for (tc of testcases) {
102-
assert.throws(() => {
103-
calculator.log.apply(this, tc.param)},
104-
tc.expected
105-
);
106-
}
107-
});
108-
109-
/* it("isFinite Error", () =>{
110-
assert.throws(() => {
111-
calculator.log(Infinity);
112-
}, {
113-
name: 'Error',
114-
message: 'unsupported operand type'
115-
});
116-
assert.throws(() => {
117-
calculator.log('abc');
118-
}, {
119-
name: 'Error',
120-
message: 'unsupported operand type'
121-
});
122-
});
123-
it("domain error (1)", () => {
124-
assert.throws(() => {
125-
calculator.log(0);
126-
}, {
127-
name: 'Error',
128-
message: 'math domain error (1)'
129-
});
130-
});
131-
it("domain error (2)", () => {
132-
assert.throws(() => {
133-
calculator.log(-1);
134-
}, {
135-
name: 'Error',
136-
message: 'math domain error (2)'
137-
});
138-
assert.throws(() => {
139-
calculator.log(-1000000);
140-
}, {
141-
name: 'Error',
142-
message: 'math domain error (2)'
143-
});
144-
});
145-
*/
146-
it("normal behavior", () => {
147-
const testcases = [
148-
{ param: [1], expected: Math.log(1) },
149-
{ param: [16], expected: Math.log(16) },
150-
{ param: [3456789], expected: Math.log(3456789) },
151-
{ param: [0.794], expected: Math.log(0.794) }
152-
];
153-
for (const tc of testcases) {
154-
assert.strictEqual(calculator.log.apply(this, tc.param), tc.expected);
155-
}
156-
});
157-
});
158-
});

lab6/llvm-pass.so.cc

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,7 @@ PreservedAnalyses LLVMPass::run(Module &M, ModuleAnalysisManager &MAM) {
1616

1717
for (auto &F : M) {
1818
errs() << "func: " << F.getName() << "\n";
19-
// if(F.getName() == "debug") {
20-
// errs() << "debug find!\n";
21-
// for(auto it = F.arg_begin(); it != F.arg_end(); it++) {
22-
// errs() << *it << "\n";
23-
// }
24-
// }
2519

26-
if(F.getName() == "main") {
27-
BasicBlock::iterator IP = F.begin()->getFirstInsertionPt();
28-
IRBuilder<> IRB(&(*IP));
29-
30-
IRB.CreateCall(debug_func, debug_arg);
31-
32-
Argument *argc = F.getArg(0);
33-
argc->replaceAllUsesWith(debug_arg);
34-
35-
Argument *argv = F.getArg(1);
36-
Value *Argv1_Ptr = IRB.CreateGEP(IRB.getInt8PtrTy(), argv, ConstantInt::get(Int32Ty, 1));
37-
Value *Argv1_Value = IRB.CreateGlobalStringPtr("hayaku... motohayaku!");
38-
IRB.CreateStore(Argv1_Value, Argv1_Ptr);
39-
40-
}
4120
}
4221
return PreservedAnalyses::none();
4322
}

0 commit comments

Comments
 (0)