occlum/demos/fish/run_per_process_config_test.sh
Hui, Chunyang 9b1d694830 Add support for per-process memory size configuration with rlimit
Rlimit are now on the same page of memory space limits defined in Occlum.json. Specific
memory size configuration can be set to child process with `prlimit` syscall or using `ulimit`
command in shell script.
2020-07-17 22:07:56 +08:00

35 lines
1006 B
Bash
Executable File

#!/bin/bash
set -e
option=$1
rm -rf occlum-test
mkdir occlum-test && cd occlum-test
occlum init
mkdir -p image/usr/bin
cp ../Occlum.json .
cp ../fish-shell/build/fish image/usr/bin
cp ../busybox/busybox image/usr/bin
cp ../test_per_process_config.sh image/bin
# Set process memory space size to very small values and will fail when running target script using default configuration
new_json="$(jq '.process.default_stack_size = "1MB" |
.process.default_heap_size = "1MB" |
.process.default_mmap_size = "6MB"' Occlum.json)" && \
echo "${new_json}" > Occlum.json
pushd image/bin
ln -s /usr/bin/busybox cat
ln -s /usr/bin/busybox echo
ln -s /usr/bin/busybox awk
popd
# If `--without-ulimit` is specified, run without ulimit command and thus will fail
if [[ $1 == "--without-ulimit" ]]; then
sed -i '/^ulimit -S/ s/^/# &/g' image/bin/test_per_process_config.sh
fi
occlum build
echo -e "\nBuild done. Running fish script ..."
occlum run /bin/test_per_process_config.sh