shmctl.cc revision 5d71de26cedae3dafc17449fe0182045c0bd20e8
1// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
2// XFAIL: android
3//
4// RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1
5// Regression test for
6// https://code.google.com/p/address-sanitizer/issues/detail?id=250
7#include <stdio.h>
8#include <sys/ipc.h>
9#include <sys/shm.h>
10#include <assert.h>
11
12int main() {
13  int id = shmget(IPC_PRIVATE, 4096, 0644 | IPC_CREAT);
14  assert(id > -1);
15  struct shmid_ds ds;
16  int res = shmctl(id, IPC_STAT, &ds);
17  assert(res > -1);
18  printf("shm_segsz: %zd\n", ds.shm_segsz);
19  assert(ds.shm_segsz == 4096);
20  assert(-1 != shmctl(id, IPC_RMID, 0));
21
22  struct shm_info shmInfo;
23  res = shmctl(0, SHM_INFO, (struct shmid_ds *)&shmInfo);
24  assert(res > -1);
25
26  return 0;
27}
28