tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
Extension
.tc
Size
2449 bytes
Lines
126
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if ( $i == "#" ) {
					i++;
					cnt = strtonum("0x" $i);
					num = NF - (i + 1);
					# The number of items is always rounded up by 4
					cnt2 = int((cnt + 3) / 4) * 4;
					if (cnt2 != num) {
						exit 1;
					}
					break;
				}
			}
		}
	// { if (NR > 30) { exit 0; } } ' trace_pipe;
}


get_buffer_data_size() {
	sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page
}

test_buffer() {

	# The id must be four bytes, test that 3 bytes fails a write
	if echo -n abc > ./trace_marker_raw ; then
		echo "Too small of write expected to fail but did not"
		echo ${ORIG} > buffer_size_kb
		exit_fail
	fi

	size=`get_buffer_data_size`
	echo size = $size

	# Now add a little more than what it can handle

	if write_buffer 0xdeadbeef $size ; then
		echo "Too big of write expected to fail but did not"
		echo ${ORIG} > buffer_size_kb
		exit_fail
	fi
}

ORIG=`cat buffer_size_kb`

# test_multiple_writes test needs at least 12KB buffer
NEW_SIZE=12

if [ ${ORIG} -lt ${NEW_SIZE} ]; then
	echo ${NEW_SIZE} > buffer_size_kb
fi

test_buffer
if ! test_multiple_writes; then
	echo ${ORIG} > buffer_size_kb
	exit_fail
fi

echo ${ORIG} > buffer_size_kb

Annotation

Implementation Notes