Xvfb?

Xvfb?

Xvfb(X Virtual Frame Buffer)는 로컬 혹은 리모트 서버에 X로 접속하거나 띄우지 않고 콘솔로만 접속하여 윈도우 콘솔 프로그램을 돌리고자 할 경우에 사용하는 Display server이다. Xvfb는 여타 다른 Display server와 다르게 보여지는 output 없이 메모리 수준에서 graphic operation을 수행한다. 따라서 Xvfb가 수행되는 서버(컴퓨터)에서는 보여주기위한 출력장치나 입력장치가 존재하지 않아도 된다(네트워크 계층만 필요).


Xvfb 사용 시나리오

Xvfb는 주로 테스트를 위해서 사용되는데 아래의 방식을 따른다.

  1. Since it shares code with the real X server, it can be used to test the parts of the code that are not related to the specific hardware.
  2. It can be used to test clients in various conditions that would otherwise require a range of different hardware; for example, it can be used to test whether clients work correctly at depths or screen sizes that are rarely supported by hardware.
  3. Background running of clients. (the xwd program or a similar program for capturing a screenshot can be used to actually see the result)
  4. Running programs that require an X server to be active even when they do not use it. (e.g. Clover html reports)

주요 기능을 요약해보자면, 특정 하드웨어와 관계없이 코드의 일부분만을 테스트할 경우에 사용되어지고, 다양한 환경(다른 해상도, 다른 화질)으로 테스트 가능하고, 백그라운드로 실행가능하며, X server를 필요로하는 프로그램들을 돌릴 경우에 사용된다.


Xvfb 설치

아래의 명령어를 통해 설치 가능하다.

1
sudo apt-get install xvfb


Xvfb plugin for Jenkins

Jenkins에 Xvfb plugin을 설치하여 사용할 수 있는데, Xvfb plugin은 빌드가 시작될 때 Xvfb를 실행시키고 빌드가 끝날때 실행을 종료시킨다. [Jenkins 관리]-[시스템설정]-[Xvfb installation]에서 설치한 Xvfb의 Setup을 할 수 있다.

image

그 다음 Job의 구성에서 Start Xvfb before the build, and shut it down after을 체크에 빌드환경을 구성할 수 있다.

image



Xvfb 사용법(console)

Screenshot example

":1"명령어를 이용해서 virtual frame buffer를 display할 수 있고 ImageMagick을 import해서 virtual screen을 image.png라는 이름으로 캡쳐할 수 있다.

1
2
3
Xvfb :1 &
xv -display :1 &
import -display :1 -window root image.png

캡쳐한 이미지는 display image.pngxv image.png 명령어로 확인할 수 있다.