162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
362306a36Sopenharmony_ci# description: Snapshot and tracing_cpumask
462306a36Sopenharmony_ci# requires: trace_marker tracing_cpumask snapshot
562306a36Sopenharmony_ci# flags: instance
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci# This testcase is constrived to reproduce a problem that the cpu buffers
862306a36Sopenharmony_ci# become unavailable which is due to 'record_disabled' of array_buffer and
962306a36Sopenharmony_ci# max_buffer being messed up.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci# Store origin cpumask
1262306a36Sopenharmony_ciORIG_CPUMASK=`cat tracing_cpumask`
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci# Stop tracing all cpu
1562306a36Sopenharmony_ciecho 0 > tracing_cpumask
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci# Take a snapshot of the main buffer
1862306a36Sopenharmony_ciecho 1 > snapshot
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci# Restore origin cpumask, note that there should be some cpus being traced
2162306a36Sopenharmony_ciecho ${ORIG_CPUMASK} > tracing_cpumask
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci# Set tracing on
2462306a36Sopenharmony_ciecho 1 > tracing_on
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci# Write a log into buffer
2762306a36Sopenharmony_ciecho "test input 1" > trace_marker
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci# Ensure the log writed so that cpu buffers are still available
3062306a36Sopenharmony_cigrep -q "test input 1" trace
3162306a36Sopenharmony_ciexit 0
32