microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
zhanxi/debug_linux_wheel

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/externals/farmhash/dev/create-self-test

24lines · modecode

1#!/bin/bash
2
3filename=$1
4outputfilename=$2
5namespace=$(basename ${filename%_gen.cc})
6
7sed "s/SKELETON/${namespace}Test/g" < self-test-skeleton.cc > "$outputfilename"
8l=$(fgrep -n 'if FARMHASH_TEST' "$filename" | cut -f 1 -d :)
9fns=$(head -n $l "$filename" | grep '^[a-z].*(const char.*size_t len.*{' | sed -e 's/.* \([A-Z]\)/\1/' -e 's/[(].*//' | sort -u)
10for fn in $fns
11do
12 [ ! -r SELFTEST$fn ] && echo "No SELFTEST$fn available! Please fix!"
13 [ -r SELFTEST$fn ] && t=$(head -1 SELFTEST$fn | sed s/NAMESPACE/$namespace/g) && sed -i "/void Dump/a $t" "$outputfilename" && \
14 b=$(tail -n 1 SELFTEST$fn | sed s/NAMESPACE/$namespace/g) && sed -i "/static int index/a $b" "$outputfilename"
15done
16# Insert special case for offset == -1: Check if the function(s) seems to do anything.
17# We're making the simplifying assumption that everything in a
18# farmhash??.cc file is available or nothing is.
19stmt0=$(fgrep -v define "$outputfilename" | fgrep 'Check(' | head -1)
20stmt1=$(fgrep -v define "$outputfilename" | fgrep 'Check(' | head -2 | tail -n 1)
21stmt2=$(fgrep -v define "$outputfilename" | fgrep 'Check(' | head -3 | tail -n 1)
22stmt=$(sed -e s/Check/IsAlive/g -e "s/ + offset//g" -e "s/len/len++/g" <<< "$stmt0 $stmt1 $stmt2")
23sed -i "/static int index/a if (offset == -1) { int alive = 0; $stmt len -= 3; return alive > 0; }" "$outputfilename"
24exit 0
25