# Setting ulimit in a test?

**URL:** https://discourse.cmake.org/t/setting-ulimit-in-a-test/8077
**Category:** Usage
**Tags:** os:linux, tool:ctest
**Created:** [May 8, 2023, 6:45pm UTC](https://discourse.cmake.org/t/setting-ulimit-in-a-test/8077 "2023-05-08T18:45:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![shabiel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/shabiel/32/1285_2.png) [@shabiel](https://discourse.cmake.org/u/shabiel)
#### Post date: [May 8, 2023, 6:45pm UTC](https://discourse.cmake.org/t/setting-ulimit-in-a-test/8077/1 "2023-05-08T18:45:40Z")

</div>

Hello everybody,

I need to artificially limit memory for a test to simulate an out of memory error (perhaps by setting ulimit). Is there a CTest way of doing that?

–Sam

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [May 8, 2023, 6:49pm UTC](https://discourse.cmake.org/t/setting-ulimit-in-a-test/8077/2 "2023-05-08T18:49:22Z")

</div>

CTest doesn’t have a native way of invoking `ulimit`. My recommendation would be to wrap your test in a shell script that calls `ulimit` at the beginning. You can pass your executable’s path to the shell script as an argument or environment variable.
