How to make cargo test show only the test which ran? - rust

I run cargo test and I get this junk before and after the actual test file:
root#ub:~/backend/utils# cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.21s
Running unittests (target/debug/deps/utils-d206bcff05f45684)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/helpers.rs (target/debug/deps/helpers-21ab86543f613060)
running 1 test
test tests::test_add ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests utils
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
So see those two running 0 tests? How can I remove them and just show the actual test that ran?

Here is a way to reduce the amount of extra output: If a particular target (library, binary) does not have any tests, then you can disable running tests in it via your Cargo.toml:
[lib]
test = false
doctest = false
[[bin]]
name = "my-binary"
test = false
That will eliminate the “running 0 tests” sections in the output of cargo test.
Of course, this creates the risk that you will later discover that you wrote a test and it isn't running, but that can be helped by adopting the test-driven-development habit of writing tests you know will fail first.

Related

Foreach loop won't run

Homework is to modify this script to take exec as an argument, but first I want to be able to run the script to try to figure out how to modify it
tcsh $ cat foreach_1
#!/bin/tcsh
# routine to zero-fill argv to 20 arguments
#
set buffer = (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
set count = 1
#
if ($#argv > 20) goto toomany
#
foreach argument ($argv[*])
set buffer[$count] = $argument
# count++
end
# REPLACE command ON THE NEXT LINE WITH
# THE PROGRAM YOU WANT TO CALL.
exec command $buffer[*]
#
toomany:
echo "Too many arguments given."
echo "Usage: foreach_1 [up to 20 arguments]"
exit 1
But I get this error when trying to run it:
./foreach_1: line 5: syntax error near unexpected token `('
./foreach_1: line 5: `set buffer = (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)'
I don't have any extra quotes, so why is this happening?
In many shells (and I believe that tcsh is counted among the bourne compatibles), you must place the left-hand side of the expression, the =, and the right-hand side all directly adjacent to one another.
# shorten the ` = ` to `=` below:
set buffer=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
set count=1
if ($#argv > 20) goto toomany
#
foreach argument ($argv[*])
set buffer[$count] = $argument
# count++
end
# REPLACE command ON THE NEXT LINE WITH
# THE PROGRAM YOU WANT TO CALL.
exec command $buffer[*]
#
toomany:
echo "Too many arguments given."
echo "Usage: foreach_1 [up to 20 arguments]"
exit 1

Error with Qhull. How could I correct it?

Basically, I am using qhull for some simple c++ implementations
dhcp-18-189-48-131:qhull-2012.1_2$ cat sample_input.txt
3 #
4
1 0 0
0 1 0
0 0 1
0 0 0
dhcp-18-189-48-131:qhull-2012.1_2$ qhull sample_input.txt
QH7036 qhull warning: missing space after flag s(73); reserved for menu. Skipped.
However, my programmes hangs with such error.... Could anyone help? Thank you.
I resolve it by doing
$ qhull < sample_input.txt
instead...

nss-3.14.1-3.fc16.src.rpm build fails with error: test suite returned failure(s)

I am trying to build nss-3.14.1-3.fc16.src.rpm on my fedora-16 with below command:
rpmbuild -ba nss.spec
and ending up with below error:
Tests summary:
Passed: 6398
Failed: 9
Failed with core: 0
Unknown status: 0
cd ../../../../
killall selfserv_9962
selfserv_9962: no process found
:
grep -c FAILED ./mozilla/tests_results/security/localhost.1/output.log
TEST_FAILURES=9
error: test suite returned failure(s)
'[' 9 -ne 0 ']'
echo 'error: test suite returned failure(s)'
exit 1
RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.G5KTZ1 (%check)
Bad exit status from /var/tmp/rpm-tmp.G5KTZ1 (%check)
Child return code was: 1
Can anyone tell me what is wrong here and what should be done to avoid these error?

perf : How to check processess running on particular cpu

Is there any option in perf to look into processes running on a particular cpu /core, and how much percentage of that core is taken by each process.
Reference links would be helpful.
perf is intended to do a profiling which is not good fit for your case. You may try to do sampling /proc/sched_debug (if it is compiled in your kernel). For example you may check which process is currently running on CPU:
egrep '^R|cpu#' /proc/sched_debug
cpu#0, 917.276 MHz
R egrep 2614 37730.177313 ...
cpu#1, 917.276 MHz
R bash 2023 218715.010833 ...
By using his PID as a key, you may check how many CPU time in milliseconds it consumed:
grep se.sum_exec_runtime /proc/2023/sched
se.sum_exec_runtime : 279346.058986
However, as #BrenoLeitão mentioned, SystemTap is quite useful for your script. Here is script for your task.
global cputimes;
global cmdline;
global oncpu;
global NS_PER_SEC = 1000000000;
probe scheduler.cpu_on {
oncpu[pid()] = local_clock_ns();
}
probe scheduler.cpu_off {
if(oncpu[pid()] == 0)
next;
cmdline[pid()] = cmdline_str();
cputimes[pid(), cpu()] <<< local_clock_ns() - oncpu[pid()];
delete oncpu[pid()];
}
probe timer.s(1) {
printf("%6s %3s %6s %s\n", "PID", "CPU", "PCT", "CMDLINE");
foreach([pid+, cpu] in cputimes) {
cpupct = #sum(cputimes[pid, cpu]) * 10000 / NS_PER_SEC;
printf("%6d %3d %3d.%02d %s\n", pid, cpu,
cpupct / 100, cpupct % 100, cmdline[pid]);
}
delete cputimes;
}
It traces moments when process is running on CPU and stops execution on that (due to migration or sleeping) by attaching to scheduler.cpu_on and scheduler.cpu_off probes. Second probe calculates time difference between these events and saves it to cputimes aggregation along with process command line arguments.
timer.s(1) fires once per second -- it walks over aggregation and calculates percentage. Here is sample output for Centos 7 with bash running infinite loop:
0 0 100.16
30 1 0.00
51 0 0.00
380 0 0.02 /usr/bin/python -Es /usr/sbin/tuned -l -P
2016 0 0.08 sshd: root#pts/0 "" "" "" ""
2023 1 100.11 -bash
2630 0 0.04 /usr/libexec/systemtap/stapio -R stap_3020c9e7ba76838179be68cd2390a10c_2630 -F3
I understand that perf is not the proper way to do it, although you can limit perf per CPU, as using perf record -C <cpulist> or even perf stat -c <cpulist>.
The close you are going to see is the context-switch event, but, this is not going to provide you the application names at all.
I think you are going to need something more powerful, as systemtap.

posting data with curl_exec on background returns 0's

I'm executing a curl command from php in background,
that uses curl_exec to retrieve some data and something is wrong...
when i try to pass post data to curl_exec script:
exec('curl --data "'.$post_string.'" '.$post_url);
all fine, i get a 200 response, script finishes successfully
same command, but with "> /dev/null &":
exec('curl --data "'.$post_string.'" '.$post_url.' > /dev/null &');
returns (taken from curl_getinfo from $post_url)
http://somurlhere.com
0
0
0
-1
0
0
0.552842
0.51867
0.552705
0.552725
0
0
0
0
0
0
0
0
How is that possible?
I'm doing something wrong?
I know that the script doesn't die, since it logs to a txt file at the end of execution...
Any ideas?
as i thought, just a stupid mistake, i was removing some data after executing the command, and since it's in background, i remove it before the second script gets a chance to access it, that was the problem =]

Resources