[dpdk-dev] [PATCH] test: make hugepage check more robust under Linux

Aaron Conole aconole at redhat.com
Tue Apr 6 14:33:07 CEST 2021


Thomas Monjalon <thomas at monjalon.net> writes:

> 17/03/2021 15:44, Aaron Conole:
>> The hugepage test really needs to check multiple things on Linux:
>> 
>> 1. Are hugepages reserved in the system?
>> 
>> 2. Is the hugepage mountpoint available so that we can allocate them?
>> 
>> 3. Do we have permissions to write into the hugepage mountpoint?
>> 
>> The existing hugepage check only verifies the first.  On some setups,
>> a non-root user won't have access to the mountpoint for hugepages to
>> be allocated and that needs to be reflected in the test as well.  Add
>> such checks for Linux OS to give a more check when running test suites.
>
> Requirements 2 & 3 are optional.
> You don't need a mount point if using the option --in-memory.

That's true, but it seems to break a few of the unit tests without.
I'll clarify the commit message.

Additionally, I thought it would be simple to just incorporate your
suggestions - but it seems that meson / ninja doesn't have cascading
dependencies the way 'make' does (or, I haven't figured out from the
syntax how to do that) - a 'run_command' gets resolved at configure
time and it doesn't seem that we can make a run_target depend on another
run_target since dependencies are on file outputs.  Maybe we do some
kind of trickery here where we write a file that the build script reads?

I am trying to figure out how best to accomplish this - suggestions
welcome.

> [...]
>> +	perm=""
>
> perm= should do the same.
>
>> +	for mount in `mount | grep hugetlbfs | awk '{ print $3; }'`; do
>
> Please prefer $() syntax.

Okay

> Are spaces in awk required?

I'm not sure - I don't think so.

>> +		test ! -w $mount/. || perm="$mount"
>
> Why /. ?

Habit.  I will remove it.

>> +	done
>> +	if [ "$perm" = "" -o "$nr_hugepages" = "0" ]; then
>
> = "" can be replaced with -z
> "0" can be simply 0

Done.

>> +		echo 0
>> +	else
>> +		echo $nr_hugepages
>> +	fi



More information about the dev mailing list