Skip to content

Commit

Permalink
fix uica PATHs
Browse files Browse the repository at this point in the history
  • Loading branch information
dderjoel committed Jun 26, 2024
1 parent 9234aff commit 61a95e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CryptOpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ INSTALLDIR="$(dirname "${0}")"
cd "${INSTALLDIR}"

#run
PATH="$(realpath ./bins/node/bin):${PATH}" \
PATH="$(realpath ./bins/uiCA):$(realpath ./bins/node/bin):${PATH}" \
/usr/bin/env node \
"./dist/CryptOpt.js" "${@}"
5 changes: 3 additions & 2 deletions src/optimizer/measure.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ export default class MeasureUtil {

// call uiCA
const uiCAArgs = ["-TPonly", "-arch", this.timer, "-raw", join(tmpDir, "binary.bin")];
const r = spawnSync("./bins/uiCA/uiCA.py", uiCAArgs);
const r = spawnSync("uiCA.py", uiCAArgs);
if (r.status != 0) {
throw new Error(
`uiCA command failed. STDERR:${r.stderr}, STDOUT: ${r.stdout}. May be because ./uiCA is not in the cwd.`,
);
}
const tpout = spawnSync("./uiCA", uiCAArgs).stdout.toString();
// "uiCA.py" is in PATH, see "./CryptOpt"-wrapper start script
const tpout = spawnSync("uiCA.py", uiCAArgs).stdout.toString();

const tp = Number(tpout);
if (isNaN(tp)) {
Expand Down
2 changes: 2 additions & 0 deletions test/optimiser/measure.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ describe("lengthMeasure", () => {
});

describe("uiCAMeasure", () => {
// this is what, in production, the ./CryptOpt wrapper script does.
vi.stubEnv("PATH", `${process.env.PATH}:${process.env.PWD}/bins/uiCA`);
it("should use the uica lib and error out if no arch is specified.", () => {
const mu = new MeasureUtil(
undefined as unknown as Measuresuite,
Expand Down

0 comments on commit 61a95e2

Please sign in to comment.