Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/tools/perf/tests/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

Quelle  bitmap.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
#include <linux/bitmap.h>
#include <perf/cpumap.h>
#include <internal/cpumap.h>
#include "tests.h"
#include "debug.h"

#define NBITS 100

static unsigned long *get_bitmap(const char *str, int nbits)
{
 struct perf_cpu_map *map = perf_cpu_map__new(str);
 unsigned long *bm;

 bm = bitmap_zalloc(nbits);

 if (map && bm) {
  int i;
  struct perf_cpu cpu;

  perf_cpu_map__for_each_cpu(cpu, i, map)
   __set_bit(cpu.cpu, bm);
 }

 perf_cpu_map__put(map);
 return bm;
}

static int test_bitmap(const char *str)
{
 unsigned long *bm = get_bitmap(str, NBITS);
 char buf[100];
 int ret;

 bitmap_scnprintf(bm, NBITS, buf, sizeof(buf));
 pr_debug("bitmap: %s\n", buf);

 ret = !strcmp(buf, str);
 free(bm);
 return ret;
}

static int test__bitmap_print(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,5"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,3,5,7,9,11,13,15,17,19,21-40"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("2-5"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,3-6,8-10,24,35-37"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,3-6,8-10,24,35-37"));
 TEST_ASSERT_VAL("failed to convert map", test_bitmap("1-10,12-20,22-30,32-40"));
 return 0;
}

DEFINE_SUITE("Print bitmap", bitmap_print);

Messung V0.5
C=95 H=99 G=96

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.