forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request iovisor#867 from shodoco/extern
Don't close extern table when a module destructs
- Loading branch information
Showing
7 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2016 Facebook, Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License") | ||
|
||
import ctypes as ct | ||
import unittest | ||
from bcc import BPF | ||
|
||
class TestSharedTable(unittest.TestCase): | ||
def test_close_extern(self): | ||
b1 = BPF(text="""BPF_TABLE_PUBLIC("array", int, int, table1, 10);""") | ||
|
||
with BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""") as b2: | ||
t2 = b2["table1"] | ||
t2[ct.c_int(1)] = ct.c_int(10) | ||
self.assertEqual(len(t2), 10) | ||
|
||
t1 = b1["table1"] | ||
self.assertEqual(t1[ct.c_int(1)].value, 10) | ||
self.assertEqual(len(t1), 10) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |