Skip to content

Commit

Permalink
Fix mem reporting test on freebsd (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin authored Oct 31, 2023
1 parent 38e7ba2 commit c80ce50
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'main'

env:
BUILDER_VERSION: v0.9.43
BUILDER_VERSION: v0.9.49
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
BUILDER_SOURCE: releases
PACKAGE_NAME: aws-c-common
Expand Down Expand Up @@ -197,10 +197,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build ${{ env.PACKAGE_NAME }} + consumers
uses: cross-platform-actions/action@v0.10.0
uses: cross-platform-actions/action@v0.20.0
with:
operating_system: openbsd
architecture: x86-64
version: '7.2'
shell: bash
run: |
Expand All @@ -209,6 +208,23 @@ jobs:
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }}
freebsd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build ${{ env.PACKAGE_NAME }} + consumers
uses: cross-platform-actions/[email protected]
with:
operating_system: freebsd
version: '13.2'
run: |
sudo pkg install -y python3 py39-urllib3 py39-pip cmake
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }}
cross_compile:
name: Cross Compile ${{matrix.arch}}
runs-on: ubuntu-20.04 # latest
Expand Down
17 changes: 16 additions & 1 deletion tests/system_resource_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,34 @@
* SPDX-License-Identifier: Apache-2.0.
*/

#include <aws/common/byte_buf.h>
#include <aws/common/device_random.h>
#include <aws/common/system_resource_util.h>

#include <aws/testing/aws_test_harness.h>

static int s_test_memory_usage_maxrss(struct aws_allocator *allocator, void *ctx) {
(void)allocator;
(void)ctx;

/*
* Note: mem usage apis currently rely on getrusage on posix systems.
* On freebsd maxrss seems to return current process rss based on testing,
* while on every other posix platform maxrss is high water mark for rss
* over the program lifetime.
* Workaround it by allocating a buffer first. Long term using procfs should
* avoid the issue.
*/
struct aws_byte_buf temp;
aws_byte_buf_init(&temp, allocator, 8 * 1024 * 1024);
ASSERT_SUCCESS(aws_device_random_buffer(&temp));

struct aws_memory_usage_stats mu;
ASSERT_SUCCESS(aws_init_memory_usage_for_current_process(&mu));

ASSERT_TRUE(mu.maxrss > 0);

aws_byte_buf_clean_up_secure(&temp);

return 0;
}

Expand Down

0 comments on commit c80ce50

Please sign in to comment.