forked from pynvme/pynvme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
114 lines (96 loc) · 3.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# BSD LICENSE
#
# Copyright (c) Crane Che <cranechu@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#SPDK infrastructure
SPDK_ROOT_DIR := $(abspath $(CURDIR)/spdk)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
C_SRCS = driver.c
LIBNAME = pynvme
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
#find the first NVMe device as the DUT
pciaddr=$(shell lspci | grep 'Non-Volatile memory' | grep -o '..:..\..' | head -1)
#reserve memory for driver
memsize=$(shell free -m | awk 'NR==2{print ($$2-$$2%4)/2}')
#pytest test targets
TESTS := driver_test.py
#cython part
clean: cython_clean
cython_clean:
@sudo rm -rf build *.o nvme.*.so cdriver.c driver_wrap.c __pycache__ .pytest_cache cov_report .coverage.* *.log scripts/__pycache__
all: cython_lib
.PHONY: all spdk doc debug
spdk:
cd spdk; make clean; ./configure --enable-debug --disable-tests --without-vhost --without-virtio --without-isal; make; cd ..
doc: cython_lib
pydocmd simple nvme++ > README.md
sed -i "1s/.*/# pynvme/" README.md
reset:
sudo ./spdk/scripts/setup.sh cleanup
sudo ./spdk/scripts/setup.sh reset
-sudo rm -f /var/tmp/pynvme.sock*
-sudo fuser -k 4420/tcp
info:
sudo ./spdk/scripts/setup.sh status
sudo cat /sys/power/mem_sleep
sudo cat /proc/meminfo
sudo cat /proc/cpuinfo
sudo cat /etc/*release
sudo lspci -s ${pciaddr} -vv
df
whoami
groups
lspci
date
pwd
git status -sb
git --no-pager log -1
setup: reset
-xhost +local: # enable GUI with root/sudo
sudo HUGEMEM=${memsize} DRIVER_OVERRIDE=uio_pci_generic ./spdk/scripts/setup.sh # use UIO only
cython_lib:
@python3 setup.py build_ext -i --force
tags:
ctags -e --c-kinds=+l -R --exclude=.git --exclude=test --exclude=ioat --exclude=bdev --exclude=snippets --exclude=env
pytest: setup info
sudo python3 -B -m pytest $(TESTS) --pciaddr=${pciaddr} -s -x -v -r Efsx
test:
-rm test.log
make pytest 2>test.log | tee -a test.log
cat test.log | grep "434 passed, 2 skipped" || exit -1
nvmt: setup # create a NVMe/TCP target on 2 cores, based on memory bdev, for local test only
sudo ./spdk/app/nvmf_tgt/nvmf_tgt -m 3 &
sleep 5
sudo ./spdk/scripts/rpc.py construct_malloc_bdev -b Malloc0 64 512
sudo ./spdk/scripts/rpc.py nvmf_create_transport -t TCP -p 4
sudo ./spdk/scripts/rpc.py nvmf_subsystem_create nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
sudo ./spdk/scripts/rpc.py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0
sudo ./spdk/scripts/rpc.py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t tcp -a 127.0.0.1 -s 4420