origin
origin copied to clipboard
Doesn't capture functions
Nice utility!
Although it doesn't find functions (even the ones that are defined in ~/.bashrc). And functions are also executable constructs, which could easily wrap any binary in ${PATH}.
~/workspace/origin/target$ top() { echo 'hey!'; /bin/ls ${@}; }
~/workspace/origin/target$ top
hey!
origin origin.o
~/workspace/origin/target$ LC_ALL=C type top
top is a function
top ()
{
echo 'hey!';
/bin/ls ${@}
}
~/workspace/origin/target$ ./origin top
'top' found in PATH as '/usr/bin/top'
'/usr/bin/top' is an executable
~/workspace/origin/target$
Hello @netikras ! It should find functions, there's a test for it in https://github.com/atorstling/origin/blob/master/tests.py#L77
It might be a priority issue or a plain bug. What happens if you rename the function to not have a name clash?
~/workspace/origin/target$ tail ~/.bashrc
top() {
echo Hey
}
top2() {
echo Hey two
}
~/workspace/origin/target$ LC_ALL=C type top
top is a function
top ()
{
echo Hey
}
~/workspace/origin/target$ LC_ALL=C type top2
top2 is a function
top2 ()
{
echo Hey two
}
~/workspace/origin/target$ ./origin top
'top' found in PATH as '/usr/bin/top'
'/usr/bin/top' is an executable
~/workspace/origin/target$ ./origin top2
no match
~/workspace/origin/target$
Env info:
~/workspace/origin/target$ LC_ALL=C bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
~/workspace/origin/target$ echo $BASH_VERSION
4.4.20(1)-release
~/workspace/origin/target$ echo $0
bash
~/workspace/origin/target$ cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=19.1
DISTRIB_CODENAME=tessa
DISTRIB_DESCRIPTION="Linux Mint 19.1 Tessa"
~/workspace/origin/target$
And I can't really launch tests...
~/workspace/origin$ ./tests.py
sys platform is linux2
Running fakechroot chroot target/jail origin
Traceback (most recent call last):
File "./tests.py", line 51, in <module>
print(check("", 2, ["origin: Usage: origin [-v] command"]));
File "./tests.py", line 44, in check
raise Exception("command '%s' exited with status %s, expected %s. Output:\n%s\n" % ( cmd, code, expected_code, all_decoded))
Exception: command 'fakechroot chroot target/jail origin ' exited with status 127, expected 2. Output:
/bin/sh: 1: fakechroot: not found
~/workspace/origin$
Ok, thanks for investigating. I'll look into it when I get back to a computer.
If you want to run tests, try "make check". You'll also need to install fakechroot on Linux. The tests run in a chrooted environment.
Thanks for the hint regd fakeroot :) Silly me...
Still, smth is off
~/workspace/origin$ ./tests.py
sys platform is linux2
Running fakechroot chroot target/jail origin
Traceback (most recent call last):
File "./tests.py", line 51, in <module>
print(check("", 2, ["origin: Usage: origin [-v] command"]));
File "./tests.py", line 44, in check
raise Exception("command '%s' exited with status %s, expected %s. Output:\n%s\n" % ( cmd, code, expected_code, all_decoded))
Exception: <exception str() failed>
~/workspace/origin$ make check
mkdir target
clang -c -o target/origin.o src/origin.c -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
clang -o target/origin target/origin.o -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -lprofiler
/usr/bin/ld: cannot find -lprofiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:59: recipe for target 'target/origin' failed
make: *** [target/origin] Error 1
:~/workspace/origin$ make clean check
rm -rf target
mkdir target
clang -c -o target/origin.o src/origin.c -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
clang -o target/origin target/origin.o -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -lprofiler
/usr/bin/ld: cannot find -lprofiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:59: recipe for target 'target/origin' failed
make: *** [target/origin] Error 1
~/workspace/origin$
Looks like youre missing libperf from google, you'll need the Mint equivalent of these deps; https://github.com/atorstling/origin/blob/master/.github/workflows/c-cpp.yml#L86
You can also try running with make check DEBUG=0
, shouldn't link that lib then..
Not to be a whiner, but... :D
~/workspace/origin$ make check DEBUG=0
clang -c -o target/origin.o src/origin.c -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
clang -o target/origin target/origin.o -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -lprofiler
/usr/bin/ld: cannot find -lprofiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:59: recipe for target 'target/origin' failed
make: *** [target/origin] Error 1
~/workspace/origin$
After installing dependencies from the YAML line you pasted above:
~/workspace/origin$ make DEBUG=0 check
clang -c -o target/origin.o src/origin.c -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
clang -o target/origin target/origin.o -std=c11 -Werror -Wno-format-nonliteral -Weverything -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -lprofiler
./run_tests.sh
setting up chroot env
running tests
sys platform is linux2
Running fakechroot chroot target/jail origin
('fakechroot chroot target/jail origin ', '', 'origin: Usage: origin [-v] command\n')
Running fakechroot chroot target/jail origin miss
('fakechroot chroot target/jail origin miss', 'no match\n', '')
Running fakechroot chroot target/jail origin ll
Traceback (most recent call last):
File "tests.py", line 58, in <module>
"'%s' is an executable" % ls_path]));
File "tests.py", line 44, in check
raise Exception("command '%s' exited with status %s, expected %s. Output:\n%s\n" % ( cmd, code, expected_code, all_decoded))
Exception: command 'fakechroot chroot target/jail origin ll' exited with status 1, expected 0. Output:
no match
Makefile:71: recipe for target 'check' failed
make: *** [check] Error 1
~/workspace/origin$
I get the same err regardless whether/where I pass the DEBUG=0
The CI is passing, so I'm suspecting something with your env. But you don't need to get it working, I can look into this later, but not right now.